예제 #1
0
 public CommandBuilder ExternalCommand(string verb)
 {
     _lastCommand = Root.AddExternalCommand(verb, _factory);
     return this;
 }
예제 #2
0
        private void AddName(Command command, Document doc, ParagraphStyle headerStyle)
        {
            var para = doc.AddParagraph(new Paragraph(headerStyle));
            para.AddSpan("NAME");
            // TODO - rather than drawing dashes, make the prior span a different color or some such
            para = doc.AddParagraph(new Paragraph());
            para.AddSpan("----");

            para = doc.AddParagraph(new Paragraph());
            para.AddSpan(VerbPath(command));
            para.AddSpan("-");
            para.AddSpan(command.Summary);
        }
예제 #3
0
        private void AddSynopsis(Command command, Document doc, ParagraphStyle headerStyle)
        {
            var para = doc.AddParagraph(new Paragraph(headerStyle));
            para.AddSpan("SYNOPSIS");
            para = doc.AddParagraph(new Paragraph());
            para.AddSpan("--------");

            para = doc.AddParagraph(new Paragraph());
            para.AddSpan(VerbPath(command));

            foreach (var named in command.NamedParameters)
            {
                para.AddSpan(named.Usage);
            }

            // TODO - pick up any positional parameters on prior verbs
            foreach (var pos in command.PositionalParameters)
            {
                para.AddSpan(pos.Usage);
            }
        }
예제 #4
0
        private Document CommandHelp(Command command)
        {
            Document doc = new Document();

            // TODO - create a "style sheet" that can be passed around
            var headerStyle = new ParagraphStyle { LinesBefore = 1 };

            AddName(command, doc, headerStyle);
            AddSynopsis(command, doc, headerStyle);

            // TODO - add long description

            AddOptions(command, doc, headerStyle);

            return doc;
        }
예제 #5
0
        private void AddOptions(Command command, Document doc, ParagraphStyle headerStyle)
        {
            var para = doc.AddParagraph(new Paragraph(headerStyle));
            para.AddSpan("OPTIONS");
            para = doc.AddParagraph(new Paragraph());
            para.AddSpan("-------");

            var descStyle = new ParagraphStyle
            {
                Indent = 3,
                LinesAfter = 1
            };

            foreach (var named in command.NamedParameters)
            {
                para = doc.AddParagraph(new Paragraph());
                para.AddSpan(named.Usage);

                foreach (var p in MarkLeft.Parse(named.Description, descStyle))
                {
                    doc.AddParagraph(p);
                }
            }

            // TODO - add positional parameters from prior verbs
            foreach (var pos in command.PositionalParameters)
            {
                para = doc.AddParagraph(new Paragraph());
                para.AddSpan(pos.Usage);

                foreach (var p in MarkLeft.Parse(pos.Description, descStyle))
                {
                    doc.AddParagraph(p);
                }
            }
        }