Skip to content

Commit

Permalink
Migrate to using a reporter method
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed Jun 19, 2022
1 parent 3ebf20c commit fbc7bf9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ namespace AppInstaller::CLI
}
if (context.Args.Contains(Execution::Args::Type::Wait))
{
system("pause");
context.Reporter.PromptForAnyKey(Resource::String::PressAnyKeyToContinue);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace AppInstaller::CLI

if (context.Args.Contains(Execution::Args::Type::Wait))
{
system("pause");
context.Reporter.PromptForAnyKey(Resource::String::PressAnyKeyToContinue);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/AppInstallerCLICore/ExecutionReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionReporter.h"
#include <conio.h>


namespace AppInstaller::CLI::Execution
Expand Down Expand Up @@ -155,6 +156,13 @@ namespace AppInstaller::CLI::Execution
}
}

int Reporter::PromptForAnyKey(Resource::LocString message, Level level)
{
auto out = GetOutputStream(level);
out << message << std::endl;
return _getch();
}

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, returns the key they pressed
int PromptForAnyKey(Resource::LocString message, 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(PressAnyKeyToContinue);
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 @@ -1281,6 +1281,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="PressAnyKeyToContinue" xml:space="preserve">
<value>Press any key 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 fbc7bf9

Please sign in to comment.