public CommandBuilder ExternalCommand(string verb) { _lastCommand = Root.AddExternalCommand(verb, _factory); return this; }
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); }
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); } }
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; }
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); } } }