csharp https://commandline.codeplex.com/上的CommandLineParser Nuget软件包的文档已过时。以下是更新的工作

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp https://commandline.codeplex.com/上的CommandLineParser Nuget软件包的文档已过时。以下是更新的工作相关的知识,希望对你有一定的参考价值。

using System;
using System.Collections.Generic;
using CommandLine;
using CommandLine.Text;

namespace CmdLineParser
{
    class Options
    {
        [Option('i', "input", Required = true, HelpText = "Input file to read.")]
        public string InputFile { get; set; }

        [Option('l', "length", DefaultValue = -1, HelpText = "The maximum number of bytes to process.")]
        public int MaximumLength { get; set; }

        [Option('v', null, HelpText = "Print details during execution.")]
        public bool Verbose { get; set; }

        [ValueList(typeof(List<string>), MaximumElements = 2)]
        public IList<string> Items { get; set; }

        [HelpOption]
        public string GetUsage()
        {
            return HelpText.AutoBuild(this, (HelpText current) =>
                HelpText.DefaultParsingErrorsHandler(this, current));
        }

        [ParserState]
        public IParserState LastParserState { get; set; }
    }

    class Program
    {

        static void Main(string[] args)
        {
            var options = new Options();
            var parser = new CommandLine.Parser();
            var result = parser.ParseArguments(args, options);
            if (result)
            {
                if (options.Verbose)
                {
                    Console.WriteLine(options.InputFile);
                    Console.WriteLine(options.MaximumLength);
                }
                else
                    Console.WriteLine("working ...");
            }
            else
            {
                Console.WriteLine(options.GetUsage());
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
    }
}

以上是关于csharp https://commandline.codeplex.com/上的CommandLineParser Nuget软件包的文档已过时。以下是更新的工作的主要内容,如果未能解决你的问题,请参考以下文章

csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp渲染,RenderPSDImageAsPath.cs

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs

csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs

csharp 例如-CSHARP-GroupDocs.Search.Examples.CSharp索引,AddDocumentToIndex.cs

csharp 例如-CSHARP-GroupDocs.Search.Examples.CSharp索引,AddDocumentToIndexAsynchronously.cs