Skip to content

Commit d60517e

Browse files
authored
Add experimental feature for font list command (#4886)
1 parent f926640 commit d60517e

32 files changed

+763
-14
lines changed

.github/actions/spelling/expect.txt

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ DUPLICATEALIAS
143143
dustojnikhummer
144144
dvinns
145145
dwgs
146+
dwrite
146147
ecfr
147148
ecfrbrowse
148149
EFGH

schemas/JSON/settings/settings.schema.0.2.json

+5
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@
287287
"description": "Enable support for the configure export command",
288288
"type": "boolean",
289289
"default": false
290+
},
291+
"fonts": {
292+
"description": "Enable support for managing fonts",
293+
"type": "boolean",
294+
"default": false
290295
}
291296
}
292297
}

src/AppInstallerCLICore/AppInstallerCLICore.vcxproj

+4
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@
364364
<ClInclude Include="Commands\ErrorCommand.h" />
365365
<ClInclude Include="Commands\ExperimentalCommand.h" />
366366
<ClInclude Include="Commands\ExportCommand.h" />
367+
<ClInclude Include="Commands\FontCommand.h" />
367368
<ClInclude Include="Commands\ImportCommand.h" />
368369
<ClInclude Include="Commands\FeaturesCommand.h" />
369370
<ClInclude Include="Commands\HashCommand.h" />
@@ -410,6 +411,7 @@
410411
<ClInclude Include="Workflows\CompletionFlow.h" />
411412
<ClInclude Include="Workflows\DependencyNodeProcessor.h" />
412413
<ClInclude Include="Workflows\DownloadFlow.h" />
414+
<ClInclude Include="Workflows\FontFlow.h" />
413415
<ClInclude Include="Workflows\ImportExportFlow.h" />
414416
<ClInclude Include="Workflows\MsiInstallFlow.h" />
415417
<ClInclude Include="Workflows\MSStoreInstallerHandler.h" />
@@ -441,6 +443,7 @@
441443
<ClCompile Include="Commands\DebugCommand.cpp" />
442444
<ClCompile Include="Commands\DownloadCommand.cpp" />
443445
<ClCompile Include="Commands\ErrorCommand.cpp" />
446+
<ClCompile Include="Commands\FontCommand.cpp" />
444447
<ClCompile Include="Commands\ImportCommand.cpp" />
445448
<ClCompile Include="Commands\PinCommand.cpp" />
446449
<ClCompile Include="Commands\RepairCommand.cpp" />
@@ -490,6 +493,7 @@
490493
<ClCompile Include="Workflows\CompletionFlow.cpp" />
491494
<ClCompile Include="Workflows\DependencyNodeProcessor.cpp" />
492495
<ClCompile Include="Workflows\DownloadFlow.cpp" />
496+
<ClCompile Include="Workflows\FontFlow.cpp" />
493497
<ClCompile Include="Workflows\ImportExportFlow.cpp" />
494498
<ClCompile Include="Workflows\MsiInstallFlow.cpp" />
495499
<ClCompile Include="Workflows\MSStoreInstallerHandler.cpp" />

src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters

+12
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@
260260
<ClInclude Include="Sixel.h">
261261
<Filter>Header Files</Filter>
262262
</ClInclude>
263+
<ClInclude Include="Commands\FontCommand.h">
264+
<Filter>Commands</Filter>
265+
</ClInclude>
266+
<ClInclude Include="Workflows\FontFlow.h">
267+
<Filter>Workflows</Filter>
268+
</ClInclude>
263269
</ItemGroup>
264270
<ItemGroup>
265271
<ClCompile Include="pch.cpp">
@@ -490,6 +496,12 @@
490496
<ClCompile Include="Sixel.cpp">
491497
<Filter>Source Files</Filter>
492498
</ClCompile>
499+
<ClCompile Include="Commands\FontCommand.cpp">
500+
<Filter>Commands</Filter>
501+
</ClCompile>
502+
<ClCompile Include="Workflows\FontFlow.cpp">
503+
<Filter>Workflows</Filter>
504+
</ClCompile>
493505
</ItemGroup>
494506
<ItemGroup>
495507
<None Include="PropertySheet.props" />

src/AppInstallerCLICore/Argument.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ namespace AppInstaller::CLI
198198
case Execution::Args::Type::IgnoreResumeLimit:
199199
return { type, "ignore-resume-limit"_liv, ArgTypeCategory::None };
200200

201+
// Font command
202+
case Execution::Args::Type::Family:
203+
return { type, "family"_liv, ArgTypeCategory::None };
204+
201205
// Configuration commands
202206
case Execution::Args::Type::ConfigurationFile:
203207
return { type, "file"_liv, 'f', ArgTypeCategory::ConfigurationSetChoice, ArgTypeExclusiveSet::ConfigurationSetChoice };
@@ -430,6 +434,8 @@ namespace AppInstaller::CLI
430434
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
431435
case Args::Type::NoProxy:
432436
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
437+
case Args::Type::Family:
438+
return Argument{ type, Resource::String::FontFamilyNameArgumentDescription, ArgumentType::Positional, false };
433439
default:
434440
THROW_HR(E_UNEXPECTED);
435441
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#include "pch.h"
4+
#include "FontCommand.h"
5+
#include "Workflows/CompletionFlow.h"
6+
#include "Workflows/WorkflowBase.h"
7+
#include "Workflows/FontFlow.h"
8+
#include "Resources.h"
9+
10+
namespace AppInstaller::CLI
11+
{
12+
using namespace AppInstaller::CLI::Execution;
13+
using namespace AppInstaller::CLI::Workflow;
14+
using namespace AppInstaller::Utility::literals;
15+
using namespace std::string_view_literals;
16+
17+
Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-font"_liv;
18+
19+
std::vector<std::unique_ptr<Command>> FontCommand::GetCommands() const
20+
{
21+
return InitializeFromMoveOnly<std::vector<std::unique_ptr<Command>>>({
22+
std::make_unique<FontListCommand>(FullName()),
23+
});
24+
}
25+
26+
Resource::LocString FontCommand::ShortDescription() const
27+
{
28+
return { Resource::String::FontCommandShortDescription };
29+
}
30+
31+
Resource::LocString FontCommand::LongDescription() const
32+
{
33+
return { Resource::String::FontCommandLongDescription };
34+
}
35+
36+
Utility::LocIndView FontCommand::HelpLink() const
37+
{
38+
return s_FontCommand_HelpLink;
39+
}
40+
41+
void FontCommand::ExecuteInternal(Execution::Context& context) const
42+
{
43+
OutputHelp(context.Reporter);
44+
}
45+
46+
std::vector<Argument> FontListCommand::GetArguments() const
47+
{
48+
return {
49+
Argument::ForType(Args::Type::Family),
50+
Argument::ForType(Args::Type::Moniker),
51+
Argument::ForType(Args::Type::Source),
52+
Argument::ForType(Args::Type::Tag),
53+
Argument::ForType(Args::Type::Exact),
54+
Argument::ForType(Args::Type::AuthenticationMode),
55+
Argument::ForType(Args::Type::AuthenticationAccount),
56+
Argument::ForType(Args::Type::AcceptSourceAgreements),
57+
};
58+
}
59+
60+
Resource::LocString FontListCommand::ShortDescription() const
61+
{
62+
return { Resource::String::FontListCommandShortDescription };
63+
}
64+
65+
Resource::LocString FontListCommand::LongDescription() const
66+
{
67+
return { Resource::String::FontListCommandLongDescription };
68+
}
69+
70+
void FontListCommand::Complete(Execution::Context& context, Args::Type valueType) const
71+
{
72+
UNREFERENCED_PARAMETER(valueType);
73+
context.Reporter.Error() << Resource::String::PendingWorkError << std::endl;
74+
THROW_HR(E_NOTIMPL);
75+
}
76+
77+
Utility::LocIndView FontListCommand::HelpLink() const
78+
{
79+
return s_FontCommand_HelpLink;
80+
}
81+
82+
void FontListCommand::ExecuteInternal(Execution::Context& context) const
83+
{
84+
context << Workflow::ReportInstalledFonts;
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
#pragma once
4+
#include "Command.h"
5+
#include <winget/UserSettings.h>
6+
7+
namespace AppInstaller::CLI
8+
{
9+
struct FontCommand final : public Command
10+
{
11+
FontCommand(std::string_view parent) : Command("font", { "fonts" }, parent, Settings::ExperimentalFeature::Feature::Font) {}
12+
13+
std::vector<std::unique_ptr<Command>> GetCommands() const override;
14+
15+
Resource::LocString ShortDescription() const override;
16+
Resource::LocString LongDescription() const override;
17+
18+
Utility::LocIndView HelpLink() const override;
19+
20+
protected:
21+
void ExecuteInternal(Execution::Context& context) const override;
22+
};
23+
24+
struct FontListCommand final : public Command
25+
{
26+
FontListCommand(std::string_view parent) : Command("list", parent) {}
27+
28+
std::vector<Argument> GetArguments() const override;
29+
30+
Resource::LocString ShortDescription() const override;
31+
Resource::LocString LongDescription() const override;
32+
33+
void Complete(Execution::Context& context, Execution::Args::Type valueType) const override;
34+
35+
Utility::LocIndView HelpLink() const override;
36+
37+
protected:
38+
void ExecuteInternal(Execution::Context& context) const override;
39+
};
40+
}

src/AppInstallerCLICore/Commands/RootCommand.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ValidateCommand.h"
1616
#include "SettingsCommand.h"
1717
#include "FeaturesCommand.h"
18+
#include "FontCommand.h"
1819
#include "ExperimentalCommand.h"
1920
#include "CompleteCommand.h"
2021
#include "ExportCommand.h"
@@ -194,6 +195,7 @@ namespace AppInstaller::CLI
194195
std::make_unique<ErrorCommand>(FullName()),
195196
std::make_unique<ResumeCommand>(FullName()),
196197
std::make_unique<RepairCommand>(FullName()),
198+
std::make_unique<FontCommand>(FullName()),
197199
#if _DEBUG
198200
std::make_unique<DebugCommand>(FullName()),
199201
#endif

src/AppInstallerCLICore/ExecutionArgs.h

+3
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ namespace AppInstaller::CLI::Execution
121121
ResumeId,
122122
IgnoreResumeLimit,
123123

124+
// Font Command
125+
Family,
126+
124127
// Configuration
125128
ConfigurationFile,
126129
ConfigurationAcceptWarning,

src/AppInstallerCLICore/Resources.h

+11
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ namespace AppInstaller::CLI::Resource
248248
WINGET_DEFINE_RESOURCE_STRINGID(FileNotFound);
249249
WINGET_DEFINE_RESOURCE_STRINGID(FilesRemainInInstallDirectory);
250250
WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError);
251+
WINGET_DEFINE_RESOURCE_STRINGID(FontCommandLongDescription);
252+
WINGET_DEFINE_RESOURCE_STRINGID(FontCommandShortDescription);
253+
WINGET_DEFINE_RESOURCE_STRINGID(FontFace);
254+
WINGET_DEFINE_RESOURCE_STRINGID(FontFaces);
255+
WINGET_DEFINE_RESOURCE_STRINGID(FontFamily);
256+
WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyNameArgumentDescription);
257+
WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths);
258+
WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription);
259+
WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription);
260+
WINGET_DEFINE_RESOURCE_STRINGID(FontVersion);
251261
WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription);
252262
WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription);
253263
WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound);
@@ -403,6 +413,7 @@ namespace AppInstaller::CLI::Resource
403413
WINGET_DEFINE_RESOURCE_STRINGID(NoAdminRepairForUserScopePackage);
404414
WINGET_DEFINE_RESOURCE_STRINGID(NoApplicableInstallers);
405415
WINGET_DEFINE_RESOURCE_STRINGID(NoExperimentalFeaturesMessage);
416+
WINGET_DEFINE_RESOURCE_STRINGID(NoInstalledFontFound);
406417
WINGET_DEFINE_RESOURCE_STRINGID(NoInstalledPackageFound);
407418
WINGET_DEFINE_RESOURCE_STRINGID(NoPackageFound);
408419
WINGET_DEFINE_RESOURCE_STRINGID(NoPackageSelectionArgumentProvided);

0 commit comments

Comments
 (0)