Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental feature for font list command #4886

Merged
merged 19 commits into from
Oct 28, 2024
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
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ DUPLICATEALIAS
dustojnikhummer
dvinns
dwgs
dwrite
ecfr
ecfrbrowse
EFGH
Expand Down
5 changes: 5 additions & 0 deletions schemas/JSON/settings/settings.schema.0.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@
"description": "Enable support for the configure export command",
"type": "boolean",
"default": false
},
"fonts": {
"description": "Enable support for managing fonts",
"type": "boolean",
"default": false
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
<ClInclude Include="Commands\ErrorCommand.h" />
<ClInclude Include="Commands\ExperimentalCommand.h" />
<ClInclude Include="Commands\ExportCommand.h" />
<ClInclude Include="Commands\FontCommand.h" />
<ClInclude Include="Commands\ImportCommand.h" />
<ClInclude Include="Commands\FeaturesCommand.h" />
<ClInclude Include="Commands\HashCommand.h" />
Expand Down Expand Up @@ -410,6 +411,7 @@
<ClInclude Include="Workflows\CompletionFlow.h" />
<ClInclude Include="Workflows\DependencyNodeProcessor.h" />
<ClInclude Include="Workflows\DownloadFlow.h" />
<ClInclude Include="Workflows\FontFlow.h" />
<ClInclude Include="Workflows\ImportExportFlow.h" />
<ClInclude Include="Workflows\MsiInstallFlow.h" />
<ClInclude Include="Workflows\MSStoreInstallerHandler.h" />
Expand Down Expand Up @@ -441,6 +443,7 @@
<ClCompile Include="Commands\DebugCommand.cpp" />
<ClCompile Include="Commands\DownloadCommand.cpp" />
<ClCompile Include="Commands\ErrorCommand.cpp" />
<ClCompile Include="Commands\FontCommand.cpp" />
<ClCompile Include="Commands\ImportCommand.cpp" />
<ClCompile Include="Commands\PinCommand.cpp" />
<ClCompile Include="Commands\RepairCommand.cpp" />
Expand Down Expand Up @@ -490,6 +493,7 @@
<ClCompile Include="Workflows\CompletionFlow.cpp" />
<ClCompile Include="Workflows\DependencyNodeProcessor.cpp" />
<ClCompile Include="Workflows\DownloadFlow.cpp" />
<ClCompile Include="Workflows\FontFlow.cpp" />
<ClCompile Include="Workflows\ImportExportFlow.cpp" />
<ClCompile Include="Workflows\MsiInstallFlow.cpp" />
<ClCompile Include="Workflows\MSStoreInstallerHandler.cpp" />
Expand Down
12 changes: 12 additions & 0 deletions src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@
<ClInclude Include="Sixel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Commands\FontCommand.h">
<Filter>Commands</Filter>
</ClInclude>
<ClInclude Include="Workflows\FontFlow.h">
<Filter>Workflows</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -490,6 +496,12 @@
<ClCompile Include="Sixel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Commands\FontCommand.cpp">
<Filter>Commands</Filter>
</ClCompile>
<ClCompile Include="Workflows\FontFlow.cpp">
<Filter>Workflows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
Expand Down
6 changes: 6 additions & 0 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ namespace AppInstaller::CLI
case Execution::Args::Type::IgnoreResumeLimit:
return { type, "ignore-resume-limit"_liv, ArgTypeCategory::None };

// Font command
case Execution::Args::Type::Family:
return { type, "family"_liv, ArgTypeCategory::None };

// Configuration commands
case Execution::Args::Type::ConfigurationFile:
return { type, "file"_liv, 'f', ArgTypeCategory::ConfigurationSetChoice, ArgTypeExclusiveSet::ConfigurationSetChoice };
Expand Down Expand Up @@ -430,6 +434,8 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::NoProxy:
return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions };
case Args::Type::Family:
return Argument{ type, Resource::String::FontFamilyNameArgumentDescription, ArgumentType::Positional, false };
default:
THROW_HR(E_UNEXPECTED);
}
Expand Down
86 changes: 86 additions & 0 deletions src/AppInstallerCLICore/Commands/FontCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "FontCommand.h"
#include "Workflows/CompletionFlow.h"
#include "Workflows/WorkflowBase.h"
#include "Workflows/FontFlow.h"
#include "Resources.h"

namespace AppInstaller::CLI
{
using namespace AppInstaller::CLI::Execution;
using namespace AppInstaller::CLI::Workflow;
using namespace AppInstaller::Utility::literals;
using namespace std::string_view_literals;

Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-font"_liv;

std::vector<std::unique_ptr<Command>> FontCommand::GetCommands() const
{
return InitializeFromMoveOnly<std::vector<std::unique_ptr<Command>>>({
std::make_unique<FontListCommand>(FullName()),
});
}

Resource::LocString FontCommand::ShortDescription() const
{
return { Resource::String::FontCommandShortDescription };
}

Resource::LocString FontCommand::LongDescription() const
{
return { Resource::String::FontCommandLongDescription };
}

Utility::LocIndView FontCommand::HelpLink() const
{
return s_FontCommand_HelpLink;
}

void FontCommand::ExecuteInternal(Execution::Context& context) const
{
OutputHelp(context.Reporter);
}

std::vector<Argument> FontListCommand::GetArguments() const
{
return {
Argument::ForType(Args::Type::Family),
Argument::ForType(Args::Type::Moniker),
Argument::ForType(Args::Type::Source),
Argument::ForType(Args::Type::Tag),
Argument::ForType(Args::Type::Exact),
Argument::ForType(Args::Type::AuthenticationMode),
Argument::ForType(Args::Type::AuthenticationAccount),
Argument::ForType(Args::Type::AcceptSourceAgreements),
ryfu-msft marked this conversation as resolved.
Show resolved Hide resolved
};
}

Resource::LocString FontListCommand::ShortDescription() const
{
return { Resource::String::FontListCommandShortDescription };
}

Resource::LocString FontListCommand::LongDescription() const
{
return { Resource::String::FontListCommandLongDescription };
}

void FontListCommand::Complete(Execution::Context& context, Args::Type valueType) const
{
UNREFERENCED_PARAMETER(valueType);
context.Reporter.Error() << Resource::String::PendingWorkError << std::endl;
THROW_HR(E_NOTIMPL);
}

Utility::LocIndView FontListCommand::HelpLink() const
{
return s_FontCommand_HelpLink;
}

void FontListCommand::ExecuteInternal(Execution::Context& context) const
{
context << Workflow::ReportInstalledFonts;
}
}
40 changes: 40 additions & 0 deletions src/AppInstallerCLICore/Commands/FontCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "Command.h"
#include <winget/UserSettings.h>

namespace AppInstaller::CLI
{
struct FontCommand final : public Command
{
FontCommand(std::string_view parent) : Command("font", { "fonts" }, parent, Settings::ExperimentalFeature::Feature::Font) {}

std::vector<std::unique_ptr<Command>> GetCommands() const override;

Resource::LocString ShortDescription() const override;
Resource::LocString LongDescription() const override;

Utility::LocIndView HelpLink() const override;

protected:
void ExecuteInternal(Execution::Context& context) const override;
};

struct FontListCommand final : public Command
{
FontListCommand(std::string_view parent) : Command("list", parent) {}

std::vector<Argument> GetArguments() const override;

Resource::LocString ShortDescription() const override;
Resource::LocString LongDescription() const override;

void Complete(Execution::Context& context, Execution::Args::Type valueType) const override;

Utility::LocIndView HelpLink() const override;

protected:
void ExecuteInternal(Execution::Context& context) const override;
};
}
2 changes: 2 additions & 0 deletions src/AppInstallerCLICore/Commands/RootCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ValidateCommand.h"
#include "SettingsCommand.h"
#include "FeaturesCommand.h"
#include "FontCommand.h"
#include "ExperimentalCommand.h"
#include "CompleteCommand.h"
#include "ExportCommand.h"
Expand Down Expand Up @@ -194,6 +195,7 @@ namespace AppInstaller::CLI
std::make_unique<ErrorCommand>(FullName()),
std::make_unique<ResumeCommand>(FullName()),
std::make_unique<RepairCommand>(FullName()),
std::make_unique<FontCommand>(FullName()),
#if _DEBUG
std::make_unique<DebugCommand>(FullName()),
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/AppInstallerCLICore/ExecutionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ namespace AppInstaller::CLI::Execution
ResumeId,
IgnoreResumeLimit,

// Font Command
Family,

// Configuration
ConfigurationFile,
ConfigurationAcceptWarning,
Expand Down
11 changes: 11 additions & 0 deletions src/AppInstallerCLICore/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(FileNotFound);
WINGET_DEFINE_RESOURCE_STRINGID(FilesRemainInInstallDirectory);
WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError);
WINGET_DEFINE_RESOURCE_STRINGID(FontCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontFace);
WINGET_DEFINE_RESOURCE_STRINGID(FontFaces);
WINGET_DEFINE_RESOURCE_STRINGID(FontFamily);
WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyNameArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths);
WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription);
WINGET_DEFINE_RESOURCE_STRINGID(FontVersion);
WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound);
Expand Down Expand Up @@ -403,6 +413,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(NoAdminRepairForUserScopePackage);
WINGET_DEFINE_RESOURCE_STRINGID(NoApplicableInstallers);
WINGET_DEFINE_RESOURCE_STRINGID(NoExperimentalFeaturesMessage);
WINGET_DEFINE_RESOURCE_STRINGID(NoInstalledFontFound);
WINGET_DEFINE_RESOURCE_STRINGID(NoInstalledPackageFound);
WINGET_DEFINE_RESOURCE_STRINGID(NoPackageFound);
WINGET_DEFINE_RESOURCE_STRINGID(NoPackageSelectionArgumentProvided);
Expand Down
Loading
Loading