Skip to content

Commit

Permalink
Feat: Wait upon command completion (#2236)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly authored Jul 6, 2022
1 parent dea9a20 commit a56372b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace AppInstaller::CLI
void Argument::GetCommon(std::vector<Argument>& args)
{
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::Wait));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::RetroStyle));
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCLICore/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ namespace AppInstaller::CLI
{
ExecuteInternal(context);
}
if (context.Args.Contains(Execution::Args::Type::Wait))
{
context.Reporter.PromptForEnter();
}
}

void Command::ValidateArgumentsInternal(Execution::Args&) const
Expand Down
7 changes: 6 additions & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ namespace AppInstaller::CLI
{
ExecuteInternal(context);
}

if (context.Args.Contains(Execution::Args::Type::Wait))
{
context.Reporter.PromptForEnter();
}
}

void RootCommand::ExecuteInternal(Execution::Context& context) const
Expand Down Expand Up @@ -198,7 +203,7 @@ namespace AppInstaller::CLI
}
else if (context.Args.Contains(Execution::Args::Type::ListVersions))
{
context.Reporter.Info() << 'v' << Runtime::GetClientVersion();
context.Reporter.Info() << 'v' << Runtime::GetClientVersion() << std::endl;
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions src/AppInstallerCLICore/ExecutionReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ namespace AppInstaller::CLI::Execution
}
}

void Reporter::PromptForEnter(Level level)
{
auto out = GetOutputStream(level);
out << std::endl << Resource::String::PressEnterToContinue << std::endl;
m_in.get();
}

void Reporter::ShowIndefiniteProgress(bool running)
{
if (m_spinner)
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLICore/ExecutionReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ namespace AppInstaller::CLI::Execution
// Prompts the user, return true if they consented.
bool PromptForBoolResponse(Resource::LocString message, Level level = Level::Info);

// Prompts the user, continues when Enter is pressed
void PromptForEnter(Level level = Level::Info);

// Used to show indefinite progress. Currently an indefinite spinner is the form of
// showing indefinite progress.
// running: shows indefinite progress if set to true, stops indefinite progress if set to false
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(PortableRegistryCollisionOverridden);
WINGET_DEFINE_RESOURCE_STRINGID(PositionArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PreserveArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PressEnterToContinue);
WINGET_DEFINE_RESOURCE_STRINGID(PrivacyStatement);
WINGET_DEFINE_RESOURCE_STRINGID(ProductCodeArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PromptOptionNo);
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,9 @@ Please specify one of them using the `--source` option to proceed.</value>
<data name="PurgeArgumentDescription" xml:space="preserve">
<value>Deletes all files and directories in the package directory (portable)</value>
</data>
<data name="PressEnterToContinue" xml:space="preserve">
<value>Press Enter to continue . . .</value>
</data>
<data name="RenameArgumentDescription" xml:space="preserve">
<value>The value to rename the executable file (portable)</value>
</data>
Expand Down

0 comments on commit a56372b

Please sign in to comment.