internal static void Register(CommandLineApplication app, Func <ILogger> getLogger) { app.Command("remove", RemoveCmd => { RemoveCmd.Command("source", SourceCmd => { CommandArgument name = SourceCmd.Argument( "name", Strings.SourcesCommandNameDescription); CommandOption configfile = SourceCmd.Option( "--configfile", Strings.Option_ConfigFile, CommandOptionType.SingleValue); SourceCmd.HelpOption("-h|--help"); SourceCmd.Description = Strings.RemoveSourceCommandDescription; SourceCmd.OnExecute(() => { var args = new RemoveSourceArgs() { Name = name.Value, Configfile = configfile.Value(), }; RemoveSourceRunner.Run(args, getLogger); return(0); }); }); RemoveCmd.Command("client-cert", ClientCertCmd => { CommandOption packagesource = ClientCertCmd.Option( "-s|--package-source", Strings.Option_PackageSource, CommandOptionType.SingleValue); CommandOption configfile = ClientCertCmd.Option( "--configfile", Strings.Option_ConfigFile, CommandOptionType.SingleValue); ClientCertCmd.HelpOption("-h|--help"); ClientCertCmd.Description = Strings.RemoveClientCertCommandDescription; ClientCertCmd.OnExecute(() => { var args = new RemoveClientCertArgs() { PackageSource = packagesource.Value(), Configfile = configfile.Value(), }; RemoveClientCertRunner.Run(args, getLogger); return(0); }); }); RemoveCmd.HelpOption("-h|--help"); RemoveCmd.Description = Strings.Remove_Description; RemoveCmd.OnExecute(() => { app.ShowHelp("remove"); return(0); }); }); }
public void Remove(string configFile, string name) { var removeSourceArgs = new RemoveSourceArgs { Configfile = configFile, Name = name, }; RemoveSourceRunner.Run(removeSourceArgs, _getLogger); }
public override void ExecuteCommand() { if (SourceProvider == null) { throw new InvalidOperationException(LocalizedResourceManager.GetString("Error_SourceProviderIsNull")); } SourcesAction action = SourcesAction.None; var actionArg = Arguments.FirstOrDefault(); if (string.IsNullOrEmpty(actionArg)) { action = SourcesAction.List; } else { if (!Enum.TryParse <SourcesAction>(actionArg, ignoreCase: true, out action)) { Console.WriteLine(LocalizedResourceManager.GetString("SourcesCommandUsageSummary")); } } switch (action) { case SourcesAction.Add: var addArgs = new AddSourceArgs() { Name = Name, Source = Source, Username = Username, Password = Password, StorePasswordInClearText = StorePasswordInClearText, ValidAuthenticationTypes = ValidAuthenticationTypes, Configfile = ConfigFile }; AddSourceRunner.Run(addArgs, () => Console); break; case SourcesAction.Update: var updateSourceArgs = new UpdateSourceArgs() { Name = Name, Source = Source, Username = Username, Password = Password, StorePasswordInClearText = StorePasswordInClearText, ValidAuthenticationTypes = ValidAuthenticationTypes, Configfile = ConfigFile }; UpdateSourceRunner.Run(updateSourceArgs, () => Console); break; case SourcesAction.Remove: var removeSourceArgs = new RemoveSourceArgs() { Name = Name, Configfile = ConfigFile }; RemoveSourceRunner.Run(removeSourceArgs, () => Console); break; case SourcesAction.Disable: var disableSourceArgs = new DisableSourceArgs() { Name = Name, Configfile = ConfigFile }; DisableSourceRunner.Run(disableSourceArgs, () => Console); break; case SourcesAction.Enable: var enableSourceArgs = new EnableSourceArgs() { Name = Name, Configfile = ConfigFile }; EnableSourceRunner.Run(enableSourceArgs, () => Console); break; case SourcesAction.List: var listSourceArgs = new ListSourceArgs() { Configfile = ConfigFile, Format = Format.ToString() }; ListSourceRunner.Run(listSourceArgs, () => Console); break; } }