forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Export/Import commands (microsoft#699)
- Loading branch information
Luis Chacón
authored
Feb 13, 2021
1 parent
986abad
commit 009e684
Showing
67 changed files
with
2,383 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,6 +245,9 @@ usersettingstest | |
USHORT | ||
Utils | ||
UWP | ||
validator | ||
valijson | ||
valueiterator | ||
vamus | ||
VERSI | ||
VERSIE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{ | ||
"$id": "https://aka.ms/winget-packages.schema.json", | ||
"$schema": "https://json-schema.org/draft/2019-09/schema#", | ||
|
||
"title": "winget Packages List Schema", | ||
"description": "Describes a list of packages for batch installs", | ||
|
||
"type": "object", | ||
"required": [ "WinGetVersion", "Sources" ], | ||
"additionalProperties": true, | ||
|
||
"properties": { | ||
"WinGetVersion": { | ||
"description": "Version of winget that generated this file", | ||
"type": "string", | ||
"pattern": "^[0-9]+\\.[0-9]\\.[0-9]$" | ||
}, | ||
|
||
"CreationDate": { | ||
"description": "Date when this list was generated", | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
|
||
"Sources": { | ||
"description": "Sources from which each package comes from", | ||
"type": "array", | ||
|
||
"items": { | ||
"description": "A source and the list of packages to install from it", | ||
"type": "object", | ||
"required": [ "SourceDetails", "Packages" ], | ||
"additionalProperties": true, | ||
|
||
"properties": { | ||
"SourceDetails": { | ||
"description": "Details about this source", | ||
"type": "object", | ||
"required": [ "Name", "Identifier", "Argument", "Type" ], | ||
"additionalProperties": true, | ||
|
||
"properties": { | ||
"Name": { | ||
"description": "Name of the source", | ||
"type": "string" | ||
}, | ||
|
||
"Identifier": { | ||
"description": "Identifier for the source", | ||
"type": "string" | ||
}, | ||
|
||
"Argument": { | ||
"description": "Argument used to install the source", | ||
"type": "string" | ||
}, | ||
|
||
"Type": { | ||
"description": "Type of the source", | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
|
||
"Packages": { | ||
"description": "Packages installed from this source", | ||
"type": "array", | ||
"required": [ "Id" ], | ||
"minItems": 1, | ||
|
||
"items": { | ||
"description": "A package to be installed from this source", | ||
"type": "object", | ||
"additionalProperties": true, | ||
"properties": { | ||
"Id": { | ||
"description": "Package ID", | ||
"type": "string" | ||
}, | ||
|
||
"Version": { | ||
"description": "Package version", | ||
"type": "string" | ||
}, | ||
|
||
"Channel": { | ||
"description": "Package channel", | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "ExportCommand.h" | ||
#include "Workflows/CompletionFlow.h" | ||
#include "Workflows/ImportExportFlow.h" | ||
#include "Workflows/WorkflowBase.h" | ||
#include "Resources.h" | ||
|
||
namespace AppInstaller::CLI | ||
{ | ||
using namespace std::string_view_literals; | ||
|
||
std::vector<Argument> ExportCommand::GetArguments() const | ||
{ | ||
return { | ||
Argument{ "output", 'o', Execution::Args::Type::OutputFile, Resource::String::OutputFileArgumentDescription, ArgumentType::Positional, true }, | ||
Argument{ "source", 's', Execution::Args::Type::Source, Resource::String::ExportSourceArgumentDescription, ArgumentType::Standard }, | ||
Argument{ "include-versions", Argument::NoAlias, Execution::Args::Type::IncludeVersions, Resource::String::ExportIncludeVersionsArgumentDescription, ArgumentType::Flag }, | ||
}; | ||
} | ||
|
||
Resource::LocString ExportCommand::ShortDescription() const | ||
{ | ||
return { Resource::String::ExportCommandShortDescription }; | ||
} | ||
|
||
Resource::LocString ExportCommand::LongDescription() const | ||
{ | ||
return { Resource::String::ExportCommandLongDescription }; | ||
} | ||
|
||
void ExportCommand::Complete(Execution::Context& context, Execution::Args::Type valueType) const | ||
{ | ||
if (valueType == Execution::Args::Type::OutputFile) | ||
{ | ||
// Intentionally output nothing to allow pass through to filesystem. | ||
return; | ||
} | ||
|
||
if (valueType == Execution::Args::Type::Source) | ||
{ | ||
context << Workflow::CompleteSourceName; | ||
return; | ||
} | ||
} | ||
|
||
std::string ExportCommand::HelpLink() const | ||
{ | ||
// TODO: point to correct location | ||
return "https://aka.ms/winget-command-export"; | ||
} | ||
|
||
void ExportCommand::ExecuteInternal(Execution::Context& context) const | ||
{ | ||
context << | ||
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Discovery) << | ||
Workflow::OpenSource << | ||
Workflow::OpenCompositeSource(Repository::PredefinedSource::Installed) << | ||
Workflow::SearchSourceForMany << | ||
Workflow::EnsureMatchesFromSearchResult(true) << | ||
Workflow::SelectVersionsToExport << | ||
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Execution) << | ||
Workflow::WriteImportFile; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include "Command.h" | ||
|
||
namespace AppInstaller::CLI | ||
{ | ||
// Command to get the set of installed packages on the system. | ||
struct ExportCommand final : public Command | ||
{ | ||
ExportCommand(std::string_view parent) : Command("export", parent, Settings::ExperimentalFeature::Feature::ExperimentalImportExport) {} | ||
|
||
std::vector<Argument> GetArguments() const override; | ||
|
||
Resource::LocString ShortDescription() const override; | ||
Resource::LocString LongDescription() const override; | ||
|
||
void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; | ||
|
||
std::string HelpLink() const override; | ||
|
||
protected: | ||
void ExecuteInternal(Execution::Context& context) const override; | ||
}; | ||
} |
Oops, something went wrong.