public void Provider_Execute_ReturnsEmpty()
        {
            var command = new ProviderCommand(_helpContextService.Object, _console, LoggerMock.GetLogger <ProviderCommand>().Object);

            var message = command.Execute();

            Assert.Equal("", message);
        }
예제 #2
0
        public void RegisterProvider(IHostProvider provider, HostProviderPriority priority)
        {
            _providerRegistry.Register(provider, priority);

            // If the provider is also a configurable component, add that to the configuration service
            if (provider is IConfigurableComponent configurableProvider)
            {
                _configurationService.AddComponent(configurableProvider);
            }

            // If the provider has custom commands to offer then create them here
            if (provider is ICommandProvider cmdProvider)
            {
                ProviderCommand providerCommand = cmdProvider.CreateCommand();
                _providerCommands.Add(providerCommand);
            }
        }
예제 #3
0
        public void RegisterProvider(IHostProvider provider, HostProviderPriority priority)
        {
            _providerRegistry.Register(provider, priority);

            // If the provider is also a configurable component, add that to the configuration service
            if (provider is IConfigurableComponent configurableProvider)
            {
                _configurationService.AddComponent(configurableProvider);
            }

            // If the provider has custom commands to offer then create them here
            if (provider is ICommandProvider cmdProvider)
            {
                ProviderCommand providerCommand = cmdProvider.CreateCommand();
                _providerCommands.Add(providerCommand);
            }

            // If the provider exposes custom diagnostics use them
            if (provider is IDiagnosticProvider diagnosticProvider)
            {
                IEnumerable <IDiagnostic> providerDiagnostics = diagnosticProvider.GetDiagnostics();
                _diagnostics.AddRange(providerDiagnostics);
            }
        }
        ProviderCommand ICommandProvider.CreateCommand()
        {
            var clearCacheCmd = new Command("clear-cache")
            {
                Description = "Clear the Azure authority cache",
                Handler     = CommandHandler.Create(ClearCacheCmd),
            };

            var orgArg = new Argument("organization")
            {
                Arity       = ArgumentArity.ExactlyOne,
                Description = "Azure DevOps organization name"
            };
            var localOpt = new Option("--local")
            {
                Description = "Target the local repository Git configuration"
            };

            var listCmd = new Command("list", "List all user account bindings")
            {
                Handler = CommandHandler.Create <string, bool, bool>(ListCmd)
            };

            listCmd.AddArgument(new Argument("organization")
            {
                Arity       = ArgumentArity.ZeroOrOne,
                Description = "(optional) Filter results by Azure DevOps organization name"
            });
            listCmd.AddOption(new Option("--show-remotes")
            {
                Description = "Also show Azure DevOps remote user bindings for the current repository"
            });
            listCmd.AddOption(new Option(new[] { "--verbose", "-v" })
            {
                Description = "Verbose output - show remote URLs"
            });

            var bindCmd = new Command("bind")
            {
                Description = "Bind a user account to an Azure DevOps organization",
                Handler     = CommandHandler.Create <string, string, bool>(BindCmd),
            };

            bindCmd.AddArgument(orgArg);
            bindCmd.AddArgument(new Argument("username")
            {
                Arity       = ArgumentArity.ExactlyOne,
                Description = "Username or email (e.g.: [email protected])"
            });
            bindCmd.AddOption(localOpt);

            var unbindCmd = new Command("unbind")
            {
                Description = "Remove user account binding for an Azure DevOps organization",
                Handler     = CommandHandler.Create <string, bool>(UnbindCmd),
            };

            unbindCmd.AddArgument(orgArg);
            unbindCmd.AddOption(localOpt);

            var rootCmd = new ProviderCommand(this);

            rootCmd.AddCommand(listCmd);
            rootCmd.AddCommand(bindCmd);
            rootCmd.AddCommand(unbindCmd);
            rootCmd.AddCommand(clearCacheCmd);
            return(rootCmd);
        }