in src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Signing/TrustedSignersCommand.cs [20:233]
internal static void Register(CommandLineApplication app,
Func<ILogger> getLogger,
Action<LogLevel> setLogLevel)
{
app.Command("trust", trustedSignersCmd =>
{
// sub-commands
trustedSignersCmd.Command("list", (listCommand) =>
{
listCommand.Description = Strings.TrustListCommandDescription;
CommandOption configFile = listCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
listCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption verbosity = listCommand.VerbosityOption();
listCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.List, algorithm: null, allowUntrustedRootOption: false, owners: null, verbosity, configFile, getLogger, setLogLevel);
});
});
trustedSignersCmd.Command("sync", (syncCommand) =>
{
syncCommand.Description = Strings.TrustSyncCommandDescription;
CommandOption configFile = syncCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
syncCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption verbosity = syncCommand.VerbosityOption(); ;
CommandArgument name = syncCommand.Argument("<NAME>",
Strings.TrustedSignerNameExists);
syncCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.Sync, algorithm: null, allowUntrustedRootOption: false, owners: null, verbosity, configFile, getLogger, setLogLevel, name: name.Value);
});
});
trustedSignersCmd.Command("remove", (syncCommand) =>
{
syncCommand.Description = Strings.TrustRemoveCommandDescription;
CommandOption configFile = syncCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
syncCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption verbosity = syncCommand.VerbosityOption();
CommandArgument name = syncCommand.Argument("<NAME>",
Strings.TrustedSignerNameToRemove);
syncCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.Remove, algorithm: null, allowUntrustedRootOption: false, owners: null, verbosity, configFile, getLogger, setLogLevel, name: name.Value);
});
});
trustedSignersCmd.Command("author", (authorCommand) =>
{
authorCommand.Description = Strings.TrustAuthorCommandDescription;
CommandOption allowUntrustedRootOption = authorCommand.Option(
"--allow-untrusted-root",
Strings.TrustCommandAllowUntrustedRoot,
CommandOptionType.NoValue);
CommandOption configFile = authorCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
authorCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption verbosity = authorCommand.VerbosityOption();
CommandArgument name = authorCommand.Argument("<NAME>",
Strings.TrustedSignerNameToAdd);
CommandArgument package = authorCommand.Argument("<PACKAGE>",
Strings.TrustLocalSignedNupkgPath);
authorCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.Author, algorithm: null, allowUntrustedRootOption.HasValue(), owners: null, verbosity, configFile, getLogger, setLogLevel, name: name.Value, sourceUrl: null, packagePath: package.Value);
});
});
trustedSignersCmd.Command("repository", (repositoryCommand) =>
{
repositoryCommand.Description = Strings.TrustRepositoryCommandDescription;
CommandOption allowUntrustedRootOption = repositoryCommand.Option(
"--allow-untrusted-root",
Strings.TrustCommandAllowUntrustedRoot,
CommandOptionType.NoValue);
CommandOption configFile = repositoryCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
repositoryCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption owners = repositoryCommand.Option(
"--owners",
Strings.TrustCommandOwners,
CommandOptionType.SingleValue);
CommandOption verbosity = repositoryCommand.VerbosityOption();
CommandArgument name = repositoryCommand.Argument("<NAME>",
Strings.TrustedSignerNameToAdd);
CommandArgument package = repositoryCommand.Argument("<PACKAGE>",
Strings.TrustLocalSignedNupkgPath);
repositoryCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.Repository, algorithm: null, allowUntrustedRootOption.HasValue(), owners: owners, verbosity, configFile, getLogger, setLogLevel, name: name.Value, sourceUrl: null, packagePath: package.Value);
});
});
trustedSignersCmd.Command("certificate", (certificateCommand) =>
{
certificateCommand.Description = Strings.TrustRepositoryCommandDescription;
CommandOption algorithm = certificateCommand.Option(
"--algorithm",
Strings.TrustCommandAlgorithm,
CommandOptionType.SingleValue);
CommandOption allowUntrustedRootOption = certificateCommand.Option(
"--allow-untrusted-root",
Strings.TrustCommandAllowUntrustedRoot,
CommandOptionType.NoValue);
CommandOption configFile = certificateCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
certificateCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption verbosity = certificateCommand.VerbosityOption();
CommandArgument name = certificateCommand.Argument("<NAME>",
Strings.TrustedCertificateSignerNameToAdd);
CommandArgument fingerprint = certificateCommand.Argument("<FINGERPRINT>",
Strings.TrustCertificateFingerprint);
certificateCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.Certificate, algorithm, allowUntrustedRootOption.HasValue(), owners: null, verbosity, configFile, getLogger, setLogLevel, name: name.Value, sourceUrl: null, packagePath: null, fingerprint: fingerprint.Value);
});
});
trustedSignersCmd.Command("source", (sourceCommand) =>
{
sourceCommand.Description = Strings.TrustSourceCommandDescription;
CommandOption configFile = sourceCommand.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
sourceCommand.HelpOption(XPlatUtility.HelpOption);
CommandOption owners = sourceCommand.Option(
"--owners",
Strings.TrustCommandOwners,
CommandOptionType.SingleValue);
CommandOption sourceUrl = sourceCommand.Option(
"--source-url",
Strings.TrustSourceUrl,
CommandOptionType.SingleValue);
CommandOption verbosity = sourceCommand.VerbosityOption();
CommandArgument name = sourceCommand.Argument("<NAME>",
Strings.TrustSourceSignerName);
sourceCommand.OnExecute(async () =>
{
return await ExecuteCommand(TrustCommand.Source, algorithm: null, allowUntrustedRootOption: false, owners, verbosity, configFile, getLogger, setLogLevel, name: name.Value, sourceUrl: sourceUrl.Value());
});
});
// Main command
trustedSignersCmd.Description = Strings.TrustCommandDescription;
CommandOption mainConfigFile = trustedSignersCmd.Option(
"--configfile",
Strings.Option_ConfigFile,
CommandOptionType.SingleValue);
trustedSignersCmd.HelpOption(XPlatUtility.HelpOption);
CommandOption mainVerbosity = trustedSignersCmd.VerbosityOption();
trustedSignersCmd.OnExecute(async () =>
{
// If no command specified then default to List command.
return await ExecuteCommand(TrustCommand.List, algorithm: null, allowUntrustedRootOption: false, owners: null, mainVerbosity, mainConfigFile, getLogger, setLogLevel);
});
});
}