예제 #1
0
        public void CanPrintUsageRequired()
        {
            var    writer = new UsageWriter(UsageTarget.Console);
            string usage  = writer.WriteArgUsage("-y", "the message", false, 4);

            Assert.AreEqual("    -y the message", usage);
        }
예제 #2
0
        public void CanPrintUsageOptional()
        {
            var    writer = new UsageWriter(UsageTarget.Console);
            string usage  = writer.WriteArgUsage("-y", "the message", true, 4);

            Assert.AreEqual("    [-y] the message", usage);
        }
예제 #3
0
        public void Usage <T>(TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            var helperWriter = new UsageWriter(writer);

            helperWriter.Write(typeof(T), this.Configuration);
        }
예제 #4
0
        internal bool ParseNoVerb(object options, LinkedList <string> args)
        {
            try
            {
                this.ParseNoVerbInternal(options, args);
                return(true);
            }
            catch (ParserException)
            {
                if (this.Configuration.ErrorOutput != null)
                {
                    var hlp = new UsageWriter(this.Configuration.ErrorOutput);
                    hlp.Write(options, this.Configuration);

                    return(false);
                }

                throw;
            }
        }