Beispiel #1
0
 public CommandPage(DocumentSet <IDocument> documentSet, ICommandLineHelpPathProvider pathProvider, CommandDocumentation model, CommandLineHelpConfiguration configuration)
 {
     m_DocumentSet   = documentSet ?? throw new ArgumentNullException(nameof(documentSet));
     m_PathProvider  = pathProvider ?? throw new ArgumentNullException(nameof(pathProvider));
     m_Command       = model ?? throw new ArgumentNullException(nameof(model));
     m_Conifguration = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
Beispiel #2
0
        public void Execute_returns_false_if_AssemblyPath_is_invalid(string assemblyPath)
        {
            // ARRANGE
            var configuration = new CommandLineHelpConfiguration()
            {
                AssemblyPath = assemblyPath,
                OutputPath   = "./some-output-path"
            };

            var sut = new CommandLineHelpCommand(m_Logger, configuration);

            // ACT
            var success = sut.Execute();

            // ASSERT
            Assert.False(success);
        }
Beispiel #3
0
        public void Execute_generates_commandlinehelp_output()
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();

            var assemblyPath         = Path.Combine(temporaryDirectory, $"myAssembly.dll");
            var xmlDocumentationPath = Path.ChangeExtension(assemblyPath, ".xml");
            var outputPath           = Path.Combine(temporaryDirectory, "output");

            CompileToFile(@"
                using CommandLine;

                public class Class1
                {
                    [Option(""option1"", Required = true)]
                    public string Option1 { get; set; }

                    [Option(""option2"", Required = true)]
                    public int Option2 { get; set; }

                    [Option(""option3"", Required = true)]
                    public int Option3 { get; set; }
                }
            ", assemblyPath, xmlDocumentationPath);

            var configuration = new CommandLineHelpConfiguration()
            {
                AssemblyPath = assemblyPath,
                OutputPath   = outputPath
            };

            var sut = new CommandLineHelpCommand(m_Logger, configuration);

            // ACT
            var success = sut.Execute();

            // ASSERT
            Assert.True(success);
            Assert.True(Directory.Exists(outputPath));
            Assert.True(File.Exists(Path.Combine(outputPath, "index.md")));
        }
Beispiel #4
0
        public void Execute_returns_false_if_OutputPath_is_invalid(string outputPath)
        {
            // ARRANGE
            using var temporaryDirectory = new TemporaryDirectory();
            var assemblyPath = Path.Combine(temporaryDirectory, "myAssembly.dll");

            File.WriteAllText(assemblyPath, "");

            var configuration = new CommandLineHelpConfiguration()
            {
                AssemblyPath = assemblyPath,
                OutputPath   = outputPath
            };

            var sut = new CommandLineHelpCommand(m_Logger, configuration);

            // ACT
            var success = sut.Execute();

            // ASSERT
            Assert.False(success);
        }
Beispiel #5
0
 public CommandLineHelpDefaultTemplate(CommandLineHelpConfiguration configuration, ICommandLineHelpPathProvider pathProvider, ILogger logger)
 {
     m_Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     m_PathProvider  = pathProvider ?? throw new ArgumentNullException(nameof(pathProvider));
     m_Logger        = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Beispiel #6
0
 public CommandLineHelpCommand(ILogger logger, CommandLineHelpConfiguration configuration)
 {
     m_Logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     m_Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
Beispiel #7
0
        public static ITemplate <ApplicationDocumentation> GetTemplate(ILogger logger, CommandLineHelpConfiguration configuration)
        {
            switch (configuration.Template.Name)
            {
            case CommandLineHelpConfiguration.TemplateName.Default:
                return(new CommandLineHelpDefaultTemplate(configuration, new DefaultCommandLineHelpPathProvider(), logger));

            default:
                throw new InvalidTemplateConfigurationException($"Unknown template '{configuration.Template.Name}'");
            }
        }