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

Work towards enforcing output localization #177

Merged
merged 10 commits into from
May 20, 2020
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
62 changes: 31 additions & 31 deletions src/AppInstallerCLICore/Argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,67 @@ namespace AppInstaller::CLI
switch (type)
{
case Args::Type::Query:
return Argument{ "query", 'q', Args::Type::Query, Resources::GetInstance().ResolveWingetString(L"QueryArgumentDescription").c_str(), ArgumentType::Positional };
return Argument{ "query", 'q', Args::Type::Query, Resource::String::QueryArgumentDescription, ArgumentType::Positional };
case Args::Type::Manifest:
return Argument{ "manifest", 'm', Args::Type::Manifest, Resources::GetInstance().ResolveWingetString(L"ManifestArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "manifest", 'm', Args::Type::Manifest, Resource::String::ManifestArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::Id:
return Argument{ "id", None, Args::Type::Id,Resources::GetInstance().ResolveWingetString(L"IdArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "id", None, Args::Type::Id,Resource::String::IdArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::Name:
return Argument{ "name", None, Args::Type::Name, Resources::GetInstance().ResolveWingetString(L"NameArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "name", None, Args::Type::Name, Resource::String::NameArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::Moniker:
return Argument{ "moniker", None, Args::Type::Moniker, Resources::GetInstance().ResolveWingetString(L"MonikerArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "moniker", None, Args::Type::Moniker, Resource::String::MonikerArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::Tag:
return Argument{ "tag", None, Args::Type::Tag, Resources::GetInstance().ResolveWingetString(L"TagArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "tag", None, Args::Type::Tag, Resource::String::TagArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::Command:
return Argument{ "command", None, Args::Type::Command, Resources::GetInstance().ResolveWingetString(L"CommandArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "command", None, Args::Type::Command, Resource::String::CommandArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::Source:
return Argument{ "source", 's', Args::Type::Source, Resources::GetInstance().ResolveWingetString(L"SourceArgumentDescription").c_str(), ArgumentType::Standard };
return Argument{ "source", 's', Args::Type::Source, Resource::String::SourceArgumentDescription, ArgumentType::Standard };
case Args::Type::Count:
return Argument{ "count", 'n', Args::Type::Count, Resources::GetInstance().ResolveWingetString(L"CountArgumentDescription").c_str(), ArgumentType::Standard };
return Argument{ "count", 'n', Args::Type::Count, Resource::String::CountArgumentDescription, ArgumentType::Standard };
case Args::Type::Exact:
return Argument{ "exact", 'e', Args::Type::Exact, Resources::GetInstance().ResolveWingetString(L"ExactArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "exact", 'e', Args::Type::Exact, Resource::String::ExactArgumentDescription, ArgumentType::Flag };
case Args::Type::Version:
return Argument{ "version", 'v', Args::Type::Version, Resources::GetInstance().ResolveWingetString(L"VersionArgumentDescription").c_str(), ArgumentType::Standard };
return Argument{ "version", 'v', Args::Type::Version, Resource::String::VersionArgumentDescription, ArgumentType::Standard };
case Args::Type::Channel:
return Argument{ "channel", 'c', Args::Type::Channel, Resources::GetInstance().ResolveWingetString(L"ChannelArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Hidden };
return Argument{ "channel", 'c', Args::Type::Channel, Resource::String::ChannelArgumentDescription, ArgumentType::Standard, Visibility::Hidden };
case Args::Type::Interactive:
return Argument{ "interactive", 'i', Args::Type::Interactive, Resources::GetInstance().ResolveWingetString(L"InteractiveArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "interactive", 'i', Args::Type::Interactive, Resource::String::InteractiveArgumentDescription, ArgumentType::Flag };
case Args::Type::Silent:
return Argument{ "silent", 'h', Args::Type::Silent, Resources::GetInstance().ResolveWingetString(L"SilentArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "silent", 'h', Args::Type::Silent, Resource::String::SilentArgumentDescription, ArgumentType::Flag };
case Args::Type::Language:
return Argument{ "lang", 'a', Args::Type::Language, Resources::GetInstance().ResolveWingetString(L"LanguageArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Hidden };
return Argument{ "lang", 'a', Args::Type::Language, Resource::String::LanguageArgumentDescription, ArgumentType::Standard, Visibility::Hidden };
case Args::Type::Log:
return Argument{ "log", 'o', Args::Type::Log, Resources::GetInstance().ResolveWingetString(L"LogArgumentDesciption").c_str(), ArgumentType::Standard };
return Argument{ "log", 'o', Args::Type::Log, Resource::String::LogArgumentDesciption, ArgumentType::Standard };
case Args::Type::Override:
return Argument{ "override", None, Args::Type::Override, Resources::GetInstance().ResolveWingetString(L"OverrideArgumentDescription").c_str(), ArgumentType::Standard, Visibility::Help };
return Argument{ "override", None, Args::Type::Override, Resource::String::OverrideArgumentDescription, ArgumentType::Standard, Visibility::Help };
case Args::Type::InstallLocation:
return Argument{ "location", 'l', Args::Type::InstallLocation, Resources::GetInstance().ResolveWingetString(L"LocationArgumentDescription").c_str(), ArgumentType::Standard };
return Argument{ "location", 'l', Args::Type::InstallLocation, Resource::String::LocationArgumentDescription, ArgumentType::Standard };
case Args::Type::HashFile:
return Argument{ "file", 'f', Args::Type::HashFile, Resources::GetInstance().ResolveWingetString(L"FileArgumentDescription").c_str(), ArgumentType::Positional, true };
return Argument{ "file", 'f', Args::Type::HashFile, Resource::String::FileArgumentDescription, ArgumentType::Positional, true };
case Args::Type::Msix:
return Argument{ "msix", 'm', Args::Type::Msix, Resources::GetInstance().ResolveWingetString(L"MsixArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "msix", 'm', Args::Type::Msix, Resource::String::MsixArgumentDescription, ArgumentType::Flag };
case Args::Type::ListVersions:
return Argument{ "versions", None, Args::Type::ListVersions, Resources::GetInstance().ResolveWingetString(L"VersionsArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "versions", None, Args::Type::ListVersions, Resource::String::VersionsArgumentDescription, ArgumentType::Flag };
case Args::Type::Help:
return Argument{ "help", APPINSTALLER_CLI_HELP_ARGUMENT_TEXT_CHAR, Args::Type::Help, Resources::GetInstance().ResolveWingetString(L"HelpArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "help", APPINSTALLER_CLI_HELP_ARGUMENT_TEXT_CHAR, Args::Type::Help, Resource::String::HelpArgumentDescription, ArgumentType::Flag };
case Args::Type::SourceName:
return Argument{ "name", 'n', Args::Type::SourceName,Resources::GetInstance().ResolveWingetString(L"SourceNameArgumentDescription").c_str(), ArgumentType::Positional, false };
return Argument{ "name", 'n', Args::Type::SourceName,Resource::String::SourceNameArgumentDescription, ArgumentType::Positional, false };
case Args::Type::SourceArg:
return Argument{ "arg", 'a', Args::Type::SourceArg, Resources::GetInstance().ResolveWingetString(L"SourceArgArgumentDescription").c_str(), ArgumentType::Positional, true };
return Argument{ "arg", 'a', Args::Type::SourceArg, Resource::String::SourceArgArgumentDescription, ArgumentType::Positional, true };
case Args::Type::SourceType:
return Argument{ "type", 't', Args::Type::SourceType, Resources::GetInstance().ResolveWingetString(L"SourceTypeArgumentDescription").c_str(), ArgumentType::Positional };
return Argument{ "type", 't', Args::Type::SourceType, Resource::String::SourceTypeArgumentDescription, ArgumentType::Positional };
case Args::Type::ValidateManifest:
return Argument{ "manifest", None, Args::Type::ValidateManifest, Resources::GetInstance().ResolveWingetString(L"ValidateManifestArgumentDescription").c_str(), ArgumentType::Positional, true };
return Argument{ "manifest", None, Args::Type::ValidateManifest, Resource::String::ValidateManifestArgumentDescription, ArgumentType::Positional, true };
case Args::Type::NoVT:
return Argument{ "no-vt", None, Args::Type::NoVT, Resources::GetInstance().ResolveWingetString(L"NoVTArguementDescription").c_str(), ArgumentType::Flag, Visibility::Hidden };
return Argument{ "no-vt", None, Args::Type::NoVT, Resource::String::NoVTArguementDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::RainbowStyle:
return Argument{ "rainbow", None, Args::Type::RainbowStyle, Resources::GetInstance().ResolveWingetString(L"RainbowArgumentDescription").c_str(), ArgumentType::Flag, Visibility::Hidden };
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, Resources::GetInstance().ResolveWingetString(L"PlainArgumentDescription").c_str(), ArgumentType::Flag, Visibility::Hidden };
return Argument{ "plain", None, Args::Type::PlainStyle, Resource::String::PlainArgumentDescription, ArgumentType::Flag, Visibility::Hidden };
case Args::Type::Force:
return Argument{ "force", None, Args::Type::Force, Resources::GetInstance().ResolveWingetString(L"ForceArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "force", None, Args::Type::Force, Resource::String::ForceArgumentDescription, ArgumentType::Flag };
case Args::Type::VerboseLogs:
return Argument{ "verbose-logs", None, Args::Type::VerboseLogs, Resources::GetInstance().ResolveWingetString(L"VerboseLogsArgumentDescription").c_str(), ArgumentType::Flag };
return Argument{ "verbose-logs", None, Args::Type::VerboseLogs, Resource::String::VerboseLogsArgumentDescription, ArgumentType::Flag };
default:
THROW_HR(E_UNEXPECTED);
}
Expand Down
20 changes: 11 additions & 9 deletions src/AppInstallerCLICore/Argument.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
#pragma once
#include "ExecutionContext.h"
#include "Resources.h"

#include <string>
#include <string_view>
Expand Down Expand Up @@ -43,22 +44,22 @@ namespace AppInstaller::CLI
// An argument to a command.
struct Argument
{
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, std::string desc) :
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, Resource::StringId desc) :
m_name(name), m_alias(alias), m_execArgType(execArgType), m_desc(std::move(desc)) {}

Argument(std::string_view name, char alias, Execution::Args::Type execArgType, std::string desc, bool required) :
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, Resource::StringId desc, bool required) :
m_name(name), m_alias(alias), m_execArgType(execArgType), m_desc(std::move(desc)), m_required(required) {}

Argument(std::string_view name, char alias, Execution::Args::Type execArgType, std::string desc, ArgumentType type) :
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type) :
m_name(name), m_alias(alias), m_execArgType(execArgType), m_desc(std::move(desc)), m_type(type) {}

Argument(std::string_view name, char alias, Execution::Args::Type execArgType, std::string desc, ArgumentType type, Visibility visibility) :
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Visibility visibility) :
m_name(name), m_alias(alias), m_execArgType(execArgType), m_desc(std::move(desc)), m_type(type), m_visibility(visibility) {}

Argument(std::string_view name, char alias, Execution::Args::Type execArgType, std::string desc, ArgumentType type, bool required) :
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, bool required) :
m_name(name), m_alias(alias), m_execArgType(execArgType), m_desc(std::move(desc)), m_type(type), m_required(required) {}

Argument(std::string_view name, char alias, Execution::Args::Type execArgType, std::string desc, ArgumentType type, Visibility visibility, bool required) :
Argument(std::string_view name, char alias, Execution::Args::Type execArgType, Resource::StringId desc, ArgumentType type, Visibility visibility, bool required) :
m_name(name), m_alias(alias), m_execArgType(execArgType), m_desc(std::move(desc)), m_type(type), m_visibility(visibility), m_required(required) {}

~Argument() = default;
Expand All @@ -75,10 +76,11 @@ namespace AppInstaller::CLI
// Gets the common arguments for all commands.
static void GetCommon(std::vector<Argument>& args);

std::string_view Name() const { return m_name; }
// Arguments are not localized at this time.
Utility::LocIndView Name() const { return Utility::LocIndView{ m_name }; }
char Alias() const { return m_alias; }
Execution::Args::Type ExecArgType() const { return m_execArgType; }
const std::string& Description() const { return m_desc; }
const Resource::StringId& Description() const { return m_desc; }
bool Required() const { return m_required; }
ArgumentType Type() const { return m_type; }
size_t Limit() const { return m_countLimit; }
Expand All @@ -90,7 +92,7 @@ namespace AppInstaller::CLI
std::string_view m_name;
char m_alias;
Execution::Args::Type m_execArgType;
std::string m_desc;
Resource::StringId m_desc;
bool m_required = false;
ArgumentType m_type = ArgumentType::Standard;
::AppInstaller::CLI::Visibility m_visibility = Visibility::Example;
Expand Down
Loading