Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Settings command by msftrubengu · Pull Request #436 · microsoft/winget-cli · GitHub
Skip to content
Merged
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
46 changes: 46 additions & 0 deletions doc/Settings.md
Original file line numberDiff line numberDiff 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
3 changes: 3 additions & 0 deletions src/AppInstallerCLI/AppInstallerCLI.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -208,6 +208,9 @@
<ProjectReference Include="..\AppInstallerRepositoryCore\AppInstallerRepositoryCore.vcxproj">
<Project>{5eb88068-5fb9-4e69-89b2-72dbc5e068f9}</Project>
</ProjectReference>
<ProjectReference Include="..\JsonCppLib\JsonCppLib.vcxproj">
<Project>{82b39fda-e86b-4713-a873-9d56de00247a}</Project>
</ProjectReference>
<ProjectReference Include="..\YamlCppLib\YamlCppLib.vcxproj">
<Project>{8bb94bb8-374f-4294-bca1-c7811514a6b7}</Project>
</ProjectReference>
Expand Down
18 changes: 10 additions & 8 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,9 +122,9 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</TreatWarningAsError>
Expand All@@ -139,7 +139,7 @@
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</TreatWarningAsError>
</ClCompile>
<Link>
Expand All@@ -152,10 +152,10 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions);CLICOREDLLBUILD</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir);$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerRepositoryCore\Public;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\YamlCppLib\yaml-cpp\include;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</TreatWarningAsError>
Expand All@@ -181,6 +181,7 @@
<ClInclude Include="Commands\RootCommand.h" />
<ClInclude Include="Commands\SourceCommand.h" />
<ClInclude Include="Commands\ValidateCommand.h" />
<ClInclude Include="Commands\SettingsCommand.h" />
<ClInclude Include="ExecutionArgs.h" />
<ClInclude Include="ExecutionContext.h" />
<ClInclude Include="ExecutionProgress.h" />
Expand DownExpand Up@@ -209,6 +210,7 @@
<ClCompile Include="Commands\RootCommand.cpp" />
<ClCompile Include="Commands\SourceCommand.cpp" />
<ClCompile Include="Commands\ValidateCommand.cpp" />
<ClCompile Include="Commands\SettingsCommand.cpp" />
<ClCompile Include="Core.cpp" />
<ClCompile Include="ExecutionContext.cpp" />
<ClCompile Include="ExecutionProgress.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,9 @@
<ClInclude Include="Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\SettingsCommand.h">
<Filter>Commands</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand DownExpand Up@@ -170,6 +173,9 @@
<ClCompile Include="Resources.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\SettingsCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 3 additions & 3 deletions src/AppInstallerCLICore/Argument.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,8 +72,8 @@ namespace AppInstaller::CLI
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resource::String::RainbowArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::PlainStyle:
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RetroStyle:
return Argument{ "retro", None, Args::Type::RetroStyle, Resource::String::RetroArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
Expand All@@ -88,7 +88,7 @@ namespace AppInstaller::CLI
args.push_back(ForType(Args::Type::Help));
args.push_back(ForType(Args::Type::NoVT));
args.push_back(ForType(Args::Type::RainbowStyle));
args.push_back(ForType(Args::Type::PlainStyle));
args.push_back(ForType(Args::Type::RetroStyle));
args.push_back(ForType(Args::Type::VerboseLogs));
}
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@
#include "SearchCommand.h"
#include "HashCommand.h"
#include "ValidateCommand.h"
#include "SettingsCommand.h"

#include "Resources.h"
#include "TableOutput.h"
Expand All@@ -26,6 +27,7 @@ namespace AppInstaller::CLI
std::make_unique<SearchCommand>(FullName()),
std::make_unique<HashCommand>(FullName()),
std::make_unique<ValidateCommand>(FullName()),
std::make_unique<SettingsCommand>(FullName()),
});
}

Expand Down
62 changes: 62 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.cpp
Original file line numberDiff line numberDiff 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";

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://aka.ms/winget-settings [](start = 16, length = 30)

Did someone create this? #Closed

Copy link
Copy Markdown
ContributorAuthor

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)

}

void SettingsCommand::ExecuteInternal(Execution::Context& context) const
{
// Show warnings only when the setting command is executed.

@JohnMcPMSJohnMcPMSJun 19, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Show warnings only when the setting command is executed. [](start = 8, length = 59)

You might want to have some text beforehand that will set up the warnings that are about to come out, rather than just showing them. #Closed

if (!User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingLoadFailure << std::endl;
for (const auto& warning : User().GetWarnings())
{
context.Reporter.Warn() << warning << std::endl;
}
}

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block feels like it should be in:

UserSettings::PrepareToShellExecuteFile()

or someting. I don't think the command should be the one responsible for understanding this process. #Closed


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.

@JohnMcPMSJohnMcPMSJun 18, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Kudos to the terminal team for this work around. [](start = 8, length = 51)

Does one have to do something special to invoke the "choose which app to use" dialog? I expected that would just be automatic. #Closed

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on the version of Windows. Previous version will fail and that's where notepad will be open. Newer versions will show the dialog.


In reply to: 442416924 [](ancestors = 442416924)

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);
}
}
}
22 changes: 22 additions & 0 deletions src/AppInstallerCLICore/Commands/SettingsCommand.h
Original file line numberDiff line numberDiff 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;
};
}
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Core.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
#include "Public/AppInstallerCLICore.h"
#include "Commands/RootCommand.h"
#include "ExecutionContext.h"
#include <winget/UserSettings.h>

using namespace winrt;
using namespace winrt::Windows::Foundation;
Expand DownExpand Up@@ -110,6 +111,11 @@ namespace AppInstaller::CLI

try
{
if (!Settings::User().GetWarnings().empty())
{
context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl;
}

command->Execute(context);
}
// Exceptions that may occur in the process of executing an arbitrary command
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionArgs.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,7 +54,7 @@ namespace AppInstaller::CLI::Execution
Force, // Generic flag to enable a command to skip some check
ListVersions, // Used in Show command to list all available versions of an app
NoVT, // Disable VirtualTerminal outputs
PlainStyle, // Makes progress display as plain
RetroStyle, // Makes progress display as retro
RainbowStyle, // Makes progress display as a rainbow
Help, // Show command usage
Info, // Show general info about WinGet
Expand Down
12 changes: 9 additions & 3 deletions src/AppInstallerCLICore/ExecutionContext.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,12 @@
// Licensed under the MIT License.
#include "pch.h"
#include "ExecutionContext.h"

#include "winget/UserSettings.h"

namespace AppInstaller::CLI::Execution
{
using namespace Settings;

namespace
{
// The context that will receive CTRL signals
Expand DownExpand Up@@ -80,14 +82,18 @@ namespace AppInstaller::CLI::Execution
{
Reporter.SetStyle(VisualStyle::NoVT);
}
else if (Args.Contains(Args::Type::PlainStyle))
else if (Args.Contains(Args::Type::RetroStyle))
{
Reporter.SetStyle(VisualStyle::Plain);
Reporter.SetStyle(VisualStyle::Retro);
}
else if (Args.Contains(Args::Type::RainbowStyle))
{
Reporter.SetStyle(VisualStyle::Rainbow);
}
else
{
Reporter.SetStyle(User().Get<Setting::ProgressBarVisualStyle>());
}
}

void Context::Terminate(HRESULT hr)
Expand Down
2 changes: 1 addition & 1 deletion src/AppInstallerCLICore/ExecutionContext.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ namespace AppInstaller::CLI::Workflow

namespace AppInstaller::CLI::Execution
{
// Names a peice of data stored in the context by a workflow step.
// Names a piece of data stored in the context by a workflow step.
// Must start at 0 to enable direct access to variant in Context.
// Max must be last and unused.
enum class Data : size_t
Expand Down
10 changes: 5 additions & 5 deletions src/AppInstallerCLICore/ExecutionProgress.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,9 +3,9 @@
#include "pch.h"
#include "ExecutionProgress.h"


namespace AppInstaller::CLI::Execution
{
using namespace Settings;
using namespace VirtualTerminal;
using namespace std::string_view_literals;

Expand DownExpand Up@@ -135,10 +135,10 @@ namespace AppInstaller::CLI::Execution
{
switch (m_style)
{
case AppInstaller::CLI::Execution::VisualStyle::NoVT:
case VisualStyle::NoVT:
// No VT means no style set
break;
case AppInstaller::CLI::Execution::VisualStyle::Plain:
case VisualStyle::Retro:
if (enabled)
{
m_out << TextFormat::Default;
Expand All@@ -148,10 +148,10 @@ namespace AppInstaller::CLI::Execution
m_out << TextFormat::Negative;
}
break;
case AppInstaller::CLI::Execution::VisualStyle::Accent:
case VisualStyle::Accent:
SetColor(m_out, TextFormat::Color::GetAccentColor(), enabled);
break;
case AppInstaller::CLI::Execution::VisualStyle::Rainbow:
case VisualStyle::Rainbow:
SetRainbowColor(m_out, i, max, enabled);
break;
default:
Expand Down
Loading