Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/AppInstallerCLICore/Commands/DumpJsonCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "DumpJsonCommand.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> DumpJsonCommand::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 },
Argument::ForType(Execution::Args::Type::AcceptSourceAgreements),
};
}

Resource::LocString DumpJsonCommand::ShortDescription() const
{
return { Resource::String::DumpJsonCommandShortDescription };
}

Resource::LocString DumpJsonCommand::LongDescription() const
{
return { Resource::String::DumpJsonCommandLongDescription };
}

void DumpJsonCommand::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 DumpJsonCommand::HelpLink() const
{
// TODO: Link?
return "";
}

void DumpJsonCommand::ExecuteInternal(Execution::Context& context) const
{
context.SetFlags(Execution::ContextFlag::TreatSourceFailuresAsWarning);

context <<
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Discovery) <<
Workflow::OpenSource() <<
Workflow::SearchSourceForMany <<
Workflow::HandleSearchResultFailures <<
Workflow::SelectVersionsToExport <<
Workflow::ReportExecutionStage(Workflow::ExecutionStage::Execution) <<
Workflow::WriteImportFile;
}
}
26 changes: 26 additions & 0 deletions src/AppInstallerCLICore/Commands/DumpJsonCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "Command.h"

namespace AppInstaller::CLI
{

struct DumpJsonCommand final : public Command
{
DumpJsonCommand(std::string_view parent) : Command("dump-json", parent) {}

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 ValidateArgumentsInternal(Execution::Args& execArgs) const override;
void ExecuteInternal(Execution::Context& context) const override;
};
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "CompleteCommand.h"
#include "ExportCommand.h"
#include "ImportCommand.h"
#include "DumpJsonCommand.h"
#include "PinCommand.h"

#include "Resources.h"
Expand Down Expand Up @@ -128,6 +129,7 @@ namespace AppInstaller::CLI
std::make_unique<CompleteCommand>(FullName()),
std::make_unique<ExportCommand>(FullName()),
std::make_unique<ImportCommand>(FullName()),
std::make_unique<DumpJsonCommand>(FullName()),
std::make_unique<PinCommand>(FullName()),
});
}
Expand Down