Skip to content

Commit

Permalink
Add prompts when installer aborts terminal or needs install location (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Flor Chacón authored Aug 12, 2022
1 parent 5390e1c commit d9f2688
Show file tree
Hide file tree
Showing 30 changed files with 970 additions and 290 deletions.
24 changes: 24 additions & 0 deletions doc/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ The `purgePortablePackage` behavior affects the default behavior for uninstallin
},
```

### Default install root

The `defaultInstallRoot` affects the install location when a package requires one. This can be overridden by the `--location` parameter. This setting is only used when a package manifest includes `InstallLocationRequired`, and the actual location is obtained by appending the package ID to the root.

```json
"installBehavior": {
"defaultInstallRoot": "C:\installRoot"
},
```

## Telemetry

The `telemetry` settings control whether winget writes ETW events that may be sent to Microsoft on a default installation of Windows.
Expand Down Expand Up @@ -183,6 +193,20 @@ The `doProgressTimeoutInSeconds` setting updates the number of seconds to wait w
}
```

## Interactivity

The `interactivity` settings control whether winget may show interactive prompts during execution. Note that this refers only to prompts shown by winget itself and not to those shown by package installers.

### disable

```json
"interactivity": {
"disable": true
},
```

If set to true, the `interactivity.disable` setting will prevent any interactive prompt from being shown.

## Experimental Features

To allow work to be done and distributed to early adopters for feedback, settings can be used to enable "experimental" features.
Expand Down
22 changes: 22 additions & 0 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@
"description": "The default root directory where packages are installed to under Machine scope. Applies to the portable installer type.",
"type": "string",
"default": "%PROGRAMFILES%/WinGet/Packages/"
},
"defaultInstallRoot": {
"description": "Default install location to use for packages that require it when not specified",
"type": "string",
"maxLength": "32767"
}
}
},
Expand Down Expand Up @@ -164,6 +169,17 @@
}
}
},
"Interactivity": {
"description": "Interactivity settings",
"type": "object",
"properties": {
"disable": {
"description": "Controls whether interactive prompts are shown by the Windows Package Manager client",
"type": "boolean",
"default": false
}
}
},
"Experimental": {
"description": "Experimental Features",
"type": "object",
Expand Down Expand Up @@ -233,6 +249,12 @@
},
"additionalItems": true
},
{
"properties": {
"interactivity": { "$ref": "#/definitions/Interactivity" }
},
"additionalItems": true
},
{
"properties": {
"experimentalFeatures": { "$ref": "#/definitions/Experimental" }
Expand Down
4 changes: 3 additions & 1 deletion src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="CompletionData.h" />
<ClInclude Include="ContextOrchestrator.h" />
<ClInclude Include="Public\COMContext.h" />
<ClInclude Include="COMContext.h" />
<ClInclude Include="Workflows\DependenciesFlow.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContextData.h" />
Expand All @@ -283,6 +283,7 @@
<ClInclude Include="Workflows\MsiInstallFlow.h" />
<ClInclude Include="Workflows\MSStoreInstallerHandler.h" />
<ClInclude Include="Workflows\PortableFlow.h" />
<ClInclude Include="Workflows\PromptFlow.h" />
<ClInclude Include="Workflows\SettingsFlow.h" />
<ClInclude Include="Workflows\ShellExecuteInstallerHandler.h" />
<ClInclude Include="Workflows\InstallFlow.h" />
Expand Down Expand Up @@ -336,6 +337,7 @@
<ClCompile Include="Workflows\MsiInstallFlow.cpp" />
<ClCompile Include="Workflows\MSStoreInstallerHandler.cpp" />
<ClCompile Include="Workflows\PortableFlow.cpp" />
<ClCompile Include="Workflows\PromptFlow.cpp" />
<ClCompile Include="Workflows\SettingsFlow.cpp" />
<ClCompile Include="Workflows\ShellExecuteInstallerHandler.cpp" />
<ClCompile Include="Workflows\InstallFlow.cpp" />
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,18 @@
<ClInclude Include="Workflows\DependencyNodeProcessor.h">
<Filter>Workflows</Filter>
</ClInclude>
<ClInclude Include="Public\COMContext.h">
<ClInclude Include="COMContext.h">
<Filter>Public</Filter>
</ClInclude>
<ClInclude Include="Workflows\PortableFlow.h">
<Filter>Workflows</Filter>
</ClInclude>
<ClInclude Include="Workflows\ArchiveFlow.h">
<Filter>Workflows</Filter>
</ClInclude>
</ClInclude>
<ClInclude Include="Workflows\PromptFlow.h">
<Filter>Workflows</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -328,9 +331,12 @@
<ClCompile Include="Workflows\PortableFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
<ClCompile Include="Workflows\PromptFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
<ClCompile Include="Workflows\ArchiveFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
args.emplace_back("disable-interactivity", NoAlias, Args::Type::DisableInteractivity, Resource::String::DisableInteractivityArgumentDescription, ArgumentType::Flag, false);
}

std::string Argument::GetUsageString() const
Expand Down
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/COMContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ namespace AppInstaller::CLI::Execution
Reporter.SetChannel(Reporter::Channel::Disabled);
Reporter.SetProgressSink(this);
SetFlags(CLI::Execution::ContextFlag::AgreementsAcceptedByCaller);
SetFlags(CLI::Execution::ContextFlag::DisableInteractivity);
}

COMContext(std::ostream& out, std::istream& in) : CLI::Execution::Context(out, in)
{
Reporter.SetProgressSink(this);
SetFlags(CLI::Execution::ContextFlag::AgreementsAcceptedByCaller);
SetFlags(CLI::Execution::ContextFlag::DisableInteractivity);
}

~COMContext() = default;
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ namespace AppInstaller::CLI
{
ExecuteInternal(context);
}

if (context.Args.Contains(Execution::Args::Type::Wait))
{
context.Reporter.PromptForEnter();
Expand Down
14 changes: 9 additions & 5 deletions src/AppInstallerCLICore/ExecutionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,26 @@ namespace AppInstaller::CLI::Execution
AdminSettingEnable,
AdminSettingDisable,

// Upgrade Command
All, // Update all installed packages to latest
IncludeUnknown, // Allow upgrades of packages with unknown versions
// Upgrade command
All, // Used in Update command to update all installed packages to latest
IncludeUnknown, // Used in Upgrade command to allow upgrades of packages with unknown versions

// Other
// Show command
ListVersions, // Used in Show command to list all available versions of an app

// Common arguments
NoVT, // Disable VirtualTerminal outputs
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
VerboseLogs, // Increases winget logging level to verbose
DisableInteractivity, // Disable interactive prompts
Wait, // Prompts the user to press any key before exiting

DependencySource, // Index source to be queried against for finding dependencies
CustomHeader, // Optional Rest source header
AcceptSourceAgreements, // Accept all source agreements
Wait, // Prompts the user to press any key before exiting

// Used for demonstration purposes
ExperimentalArg,
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerCLICore/ExecutionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace AppInstaller::CLI::Execution
// TODO: Remove when the source interface is refactored.
TreatSourceFailuresAsWarning = 0x10,
ShowSearchResultsOnPartialFailure = 0x20,
DisableInteractivity = 0x40,
};

DEFINE_ENUM_FLAG_OPERATORS(ContextFlag);
Expand Down
28 changes: 27 additions & 1 deletion src/AppInstallerCLICore/ExecutionReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,32 @@ namespace AppInstaller::CLI::Execution
m_in.get();
}

std::filesystem::path Reporter::PromptForPath(Resource::LocString message, Level level)
{
auto out = GetOutputStream(level);

// Try prompting until we get a valid answer
for (;;)
{
out << message << ' ';

// Read the response
std::string response;
if (!std::getline(m_in, response))
{
THROW_HR(APPINSTALLER_CLI_ERROR_PROMPT_INPUT_ERROR);
}

// Validate the path
std::filesystem::path path{ response };
if (path.is_absolute())
{
return path;
}
}

}

void Reporter::ShowIndefiniteProgress(bool running)
{
if (m_spinner)
Expand All @@ -186,7 +212,7 @@ namespace AppInstaller::CLI::Execution
m_progressBar->ShowProgress(current, maximum, type);
}
}

void Reporter::BeginProgress()
{
GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::DisableShow;
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLICore/ExecutionReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ namespace AppInstaller::CLI::Execution
// Prompts the user, continues when Enter is pressed
void PromptForEnter(Level level = Level::Info);

// Prompts the user for a path.
std::filesystem::path PromptForPath(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
11 changes: 10 additions & 1 deletion src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(CompleteCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(CompleteCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(CountArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(CountOutOfBoundsError);
WINGET_DEFINE_RESOURCE_STRINGID(DependenciesFlowInstall);
WINGET_DEFINE_RESOURCE_STRINGID(DependenciesFlowSourceNotFound);
WINGET_DEFINE_RESOURCE_STRINGID(DependenciesFlowSourceTooManyMatches);
Expand All @@ -56,8 +57,8 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(DependenciesFlowContainsLoop);
WINGET_DEFINE_RESOURCE_STRINGID(DependenciesManagementError);
WINGET_DEFINE_RESOURCE_STRINGID(DependenciesManagementExitMessage);
WINGET_DEFINE_RESOURCE_STRINGID(CountOutOfBoundsError);
WINGET_DEFINE_RESOURCE_STRINGID(DisabledByGroupPolicy);
WINGET_DEFINE_RESOURCE_STRINGID(DisableInteractivityArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(Done);
WINGET_DEFINE_RESOURCE_STRINGID(ExactArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ExperimentalArgumentDescription);
Expand Down Expand Up @@ -121,6 +122,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(InstallCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(InstalledPackageNotAvailable);
WINGET_DEFINE_RESOURCE_STRINGID(InstalledPackageVersionNotAvailable);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerAbortsTerminal);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerElevationExpected);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerBlockedByPolicy);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerFailedSecurityCheck);
Expand All @@ -133,6 +135,9 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(InstallerHashVerified);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerLogAvailable);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerProhibitsElevation);
WINGET_DEFINE_RESOURCE_STRINGID(InstallerRequiresInstallLocation);
WINGET_DEFINE_RESOURCE_STRINGID(InstallersAbortTerminal);
WINGET_DEFINE_RESOURCE_STRINGID(InstallersRequireInstallLocation);
WINGET_DEFINE_RESOURCE_STRINGID(InstallFlowInstallSuccess);
WINGET_DEFINE_RESOURCE_STRINGID(InstallFlowRegistrationDeferred);
WINGET_DEFINE_RESOURCE_STRINGID(InstallFlowReturnCodeAlreadyInstalled);
Expand All @@ -152,6 +157,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(InstallFlowReturnCodeRebootRequiredToFinish);
WINGET_DEFINE_RESOURCE_STRINGID(InstallFlowStartingPackageInstall);
WINGET_DEFINE_RESOURCE_STRINGID(InstallForceArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(InstallLocationNotProvided);
WINGET_DEFINE_RESOURCE_STRINGID(InstallScopeDescription);
WINGET_DEFINE_RESOURCE_STRINGID(InteractiveArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(InvalidAliasError);
Expand Down Expand Up @@ -231,15 +237,18 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(PressEnterToContinue);
WINGET_DEFINE_RESOURCE_STRINGID(PrivacyStatement);
WINGET_DEFINE_RESOURCE_STRINGID(ProductCodeArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PromptForInstallRoot);
WINGET_DEFINE_RESOURCE_STRINGID(PromptOptionNo);
WINGET_DEFINE_RESOURCE_STRINGID(PromptOptionYes);
WINGET_DEFINE_RESOURCE_STRINGID(PromptToProceed);
WINGET_DEFINE_RESOURCE_STRINGID(PurgeArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(PurgeInstallDirectory);
WINGET_DEFINE_RESOURCE_STRINGID(QueryArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(RainbowArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(RelatedLink);
WINGET_DEFINE_RESOURCE_STRINGID(RenameArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ReparsePointsNotSupportedError);
WINGET_DEFINE_RESOURCE_STRINGID(ReportIdentityForAgreements);
WINGET_DEFINE_RESOURCE_STRINGID(ReportIdentityFound);
WINGET_DEFINE_RESOURCE_STRINGID(RequiredArgError);
WINGET_DEFINE_RESOURCE_STRINGID(ReservedFilenameError);
Expand Down
Loading

0 comments on commit d9f2688

Please sign in to comment.