private void WriteArgumentDescriptions(ModelHelp modelHelp) { var items = modelHelp.Members.OrderByDescending(m => m.OrdinalIndex.HasValue) .ThenBy(m => m.OrdinalIndex) .ToDictionary(ks => ks.OrdinalIndex.HasValue ? ks.Name : GetFullSwitchString(modelHelp.SwitchDelimiter, ks.Switches), es => es.HelpText); WriteJustifiedOutput(items, ArgumentDescriptionPadding); }
public void WriteHelp(ModelHelp modelHelp, TextWriter textWriter) { if (!string.IsNullOrWhiteSpace(modelHelp.HelpText)) { WriteDescription(modelHelp.HelpText, textWriter); } WriteUsage(modelHelp, textWriter); WriteSwitches(modelHelp, textWriter); }
private void WriteArgumentDescriptions(ModelHelp modelHelp) { var helpMembers = GetHelpMembers(modelHelp); var items = helpMembers .Where(m => string.IsNullOrEmpty(m.HelpText) == false) .ToDictionary(ks => ks.OrdinalIndex.HasValue ? ks.Name : GetFullSwitchString(modelHelp.SwitchDelimiter, ks.Switches), es => es.HelpText); WriteJustifiedOutput(items, ArgumentDescriptionPadding); }
private void WriteArgumentDescriptions(ModelHelp modelHelp) { var items = modelHelp.Members .Where(m => String.IsNullOrEmpty(m.HelpText) == false) .OrderByDescending(m => m.OrdinalIndex.HasValue) .ThenBy(m => m.OrdinalIndex) .ToDictionary(ks => ks.OrdinalIndex.HasValue ? ks.Name : GetFullSwitchString(modelHelp.SwitchDelimiter, ks.Switches), es => es.HelpText); WriteJustifiedOutput(items, ArgumentDescriptionPadding); }
public virtual void WriteHelp(ModelHelp modelHelp, TextWriter writer) { Output = writer; WriteJustifiedItem(String.Empty, modelHelp.HelpText, 0); WriteUsage(modelHelp, writer); Output.WriteLine(); Output.WriteLine(); WriteArgumentDescriptions(modelHelp); }
/// <summary> /// A helper method for getting the formatted help text into a string /// </summary> /// <param name="source">The implemented help formatter</param> /// <param name="modelHelp">The data structure that contains the help information</param> /// <returns></returns> public static string GetHelp(this IHelpFormatter source, ModelHelp modelHelp) { if (source == null) throw new ArgumentNullException("source"); var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) { source.WriteHelp(modelHelp, writer); } return builder.ToString(); }
protected virtual void WriteUsage(ModelHelp modelHelp, TextWriter writer) { var helpMembers = GetHelpMembers(modelHelp); var values = helpMembers.Select(m => m.OrdinalIndex.HasValue ? m.Name : GetFullSwitchString(modelHelp.SwitchDelimiter, m.Switches)); //TODO: Figure out actual command name? var dictionary = new Dictionary <string, string> { { "<command>", string.Join(" ", values.ToArray()) } }; WriteJustifiedOutput(dictionary, CommandSamplePadding); }
private static IEnumerable <MemberHelp> GetHelpMembers(ModelHelp modelHelp) { var ordinals = modelHelp.Members .Where(m => m.OrdinalIndex.HasValue) .OrderBy(m => m.OrdinalIndex.Value); var switches = modelHelp.Members .Where(m => m.OrdinalIndex.HasValue == false) .OrderBy(m => m.Name); var memberHelps = ordinals.Concat(switches); return(memberHelps); }
public virtual void WriteHelp(ModelHelp modelHelp, TextWriter writer) { Output = writer; if (string.IsNullOrEmpty(modelHelp.HelpText) == false) { WriteJustifiedItem(string.Empty, modelHelp.HelpText, 0); } WriteUsage(modelHelp, writer); Output.WriteLine(); WriteArgumentDescriptions(modelHelp); }
/// <summary> /// A helper method for getting the formatted help text into a string /// </summary> /// <param name="source">The implemented help formatter</param> /// <param name="modelHelp">The data structure that contains the help information</param> /// <returns></returns> public static string GetHelp(this IHelpFormatter source, ModelHelp modelHelp) { if (source == null) { throw new ArgumentNullException("source"); } var builder = new StringBuilder(); using (var writer = new StringWriter(builder)) { source.WriteHelp(modelHelp, writer); } return(builder.ToString()); }
override protected void WriteUsage(ModelHelp modelHelp, TextWriter writer) { var values = modelHelp.Members.Where(m => m.OrdinalIndex.HasValue && m.OrdinalIndex != 0) .OrderBy(m => m.OrdinalIndex.Value) .Select(m => m.Name) .Concat(modelHelp.Members .Where(m => m.OrdinalIndex.HasValue == false) .Select(m => String.Format("[{0}]", String.Join("|", m.Switches.Select(s => modelHelp.SwitchDelimiter + s).ToArray())))); var dictionary = new Dictionary <string, string> { { this._cmdName, String.Join(" ", values.ToArray()) } }; WriteJustifiedOutput(dictionary, CommandSamplePadding); }
protected virtual void WriteUsage(ModelHelp modelHelp, TextWriter writer) { var values = modelHelp.Members.Where(m => m.OrdinalIndex.HasValue) .OrderBy(m => m.OrdinalIndex.Value) .Select(m => m.Name) .Concat(modelHelp.Members .Where(m => m.OrdinalIndex.HasValue == false) .Select(m => String.Format("[{0}{1}]", modelHelp.SwitchDelimiter, m.Switches.First()))); //TODO: Figure out actual command name? var dictionary = new Dictionary <string, string> { { "<command>", String.Join(" ", values.ToArray()) } }; WriteJustifiedOutput(dictionary, CommandSamplePadding); }
private void WriteSwitches(ModelHelp modelHelp, TextWriter textWriter) { if (modelHelp == null) { throw new ArgumentNullException("modelHelp"); } if (textWriter == null) { throw new ArgumentNullException("textWriter"); } foreach (var member in modelHelp.Members) { var memberSwitch = member.Switches.Single(); textWriter.Write(" {0}{1}", modelHelp.SwitchDelimiter, memberSwitch); var spaces = new string(' ', 3 - memberSwitch.Length); textWriter.Write(spaces); textWriter.WriteLine("{0}", member.HelpText); } }
private void WriteUsage(ModelHelp modelHelp, TextWriter textWriter) { if (modelHelp == null) { throw new ArgumentNullException("modelHelp"); } if (textWriter == null) { throw new ArgumentNullException("textWriter"); } var location = Assembly.GetEntryAssembly().Location; textWriter.Write(Path.GetFileNameWithoutExtension(location)); foreach (var member in modelHelp.Members) { textWriter.Write(" [{0}]", modelHelp.SwitchDelimiter + member.Switches.Single()); } textWriter.WriteLine(" URL"); textWriter.WriteLine(); }
protected virtual void WriteUsage(ModelHelp modelHelp, TextWriter writer) { var values = modelHelp.Members.Where(m => m.OrdinalIndex.HasValue) .OrderBy(m => m.OrdinalIndex.Value) .Select(m => m.Name) .Concat(modelHelp.Members .Where(m => m.OrdinalIndex.HasValue == false) .Select(m => String.Format("[{0}]", String.Join("|", m.Switches.Select(s => modelHelp.SwitchDelimiter + s).ToArray())))); //TODO: Figure out actual command name? var dictionary = new Dictionary<string, string> { {"<command>", String.Join(" ", values.ToArray())} }; WriteJustifiedOutput(dictionary, CommandSamplePadding); }