Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Settings command#436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Settings command #436
Changes from all commits
e044e8bc6270f03b09d2bbf0b051771057589717179ae69a798f6688e4dfd72c6d298f0c29cc3db2d024d80334b2e9d526100c5c7File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # WinGet CLI Settings | ||
| You can configure WinGet by editing the `settings.json` file. The file can be open with the default json editor by running `winget settings`. If no editor is configure, notepad.exe will be used. | ||
| ## File Location | ||
| Settings file is located in %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json | ||
| If you are using the non-packaged winget version by building it from source code the file will %LOCALAPPDATA%\Microsoft\WinGet\Settings\settings.json | ||
| ## Source | ||
| These settings involve configuration to the WinGet source. | ||
| ``` | ||
| "source": { | ||
| "autoUpdateIntervalInMinutes": 3 | ||
| }, | ||
| ``` | ||
| ### autoUpdateIntervalInMinutes | ||
| Positive integer that represents the interval in minutes of how often to automatically check for updates to a WinGet source. The check for updates only happens when a source is used, and if no update is available the interval will be reset. | ||
| - Minimum: 0 | ||
| - Default: 5 | ||
| To manually update the source use `winget source update` | ||
| ## Visual | ||
| These settings involve visual elements that are displayed by WinGet | ||
| ``` | ||
| "visual": { | ||
| "progressBar": "accent" | ||
| } | ||
| ``` | ||
| ### progressBar | ||
| Color of the progress bar that WinGet displays when not specified by arguments. | ||
| - accent (default) | ||
| - retro | ||
| - rainbow |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| #include "pch.h" | ||
| #include "SettingsCommand.h" | ||
| #include "Workflows/WorkflowBase.h" | ||
| #include "Resources.h" | ||
| #include <winget/UserSettings.h> | ||
| namespace AppInstaller::CLI | ||
| { | ||
| using namespace Utility::literals; | ||
| using namespace AppInstaller::Settings; | ||
| using namespace std::string_view_literals; | ||
| std::vector<Argument> SettingsCommand::GetArguments() const | ||
| { | ||
| return {}; | ||
| } | ||
| Resource::LocString SettingsCommand::ShortDescription() const | ||
| { | ||
| return { Resource::String::SettingsCommandShortDescription }; | ||
| } | ||
| Resource::LocString SettingsCommand::LongDescription() const | ||
| { | ||
| return { Resource::String::SettingsCommandLongDescription }; | ||
| } | ||
| std::string SettingsCommand::HelpLink() const | ||
| { | ||
| return "https://aka.ms/winget-settings"; | ||
| } | ||
| void SettingsCommand::ExecuteInternal(Execution::Context& context) const | ||
| { | ||
| // Show warnings only when the setting command is executed. | ||
| ||
| if (!User().GetWarnings().empty()) | ||
| { | ||
| context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl; | ||
| for (const auto& warning : User().GetWarnings()) | ||
| { | ||
| context.Reporter.Warn() << warning << std::endl; | ||
| } | ||
| } | ||
| ||
| User().PrepareToShellExecuteFile(); | ||
| auto filePathUTF16 = UserSettings::SettingsFilePath().wstring(); | ||
| // Some versions of windows will fail if no file extension association exists, other will pop up the dialog | ||
| // to make the user pick their default. | ||
| // Kudos to the terminal team for this work around. | ||
| ||
| HINSTANCE res = ShellExecuteW(nullptr, nullptr, filePathUTF16.c_str(), nullptr, nullptr, SW_SHOW); | ||
| if (static_cast<int>(reinterpret_cast<uintptr_t>(res)) <= 32) | ||
| { | ||
| // User doesn't have file type association. Default to notepad | ||
| ShellExecuteW(nullptr, nullptr, L"notepad", filePathUTF16.c_str(), nullptr, SW_SHOW); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| #pragma once | ||
| #include "Command.h" | ||
| namespace AppInstaller::CLI | ||
| { | ||
| struct SettingsCommand final : public Command | ||
| { | ||
| SettingsCommand(std::string_view parent) : Command("settings", parent) {} | ||
| virtual std::vector<Argument> GetArguments() const override; | ||
| virtual Resource::LocString ShortDescription() const override; | ||
| virtual Resource::LocString LongDescription() const override; | ||
| std::string HelpLink() const override; | ||
| protected: | ||
| void ExecuteInternal(Execution::Context& context) const override; | ||
| }; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did someone create this? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did, is not pointing to docs right now, but will update it once settings.md is on master
In reply to: 442413601 [](ancestors = 442413601)