public static void PrintHelpMessage(TextWriter outputWriter, ICommandProvider commandProvider) { var c = commandProvider.Commands; var o = commandProvider.Options.OrderBy(_ => _.Long); var name = Name; var w = Wrap(outputWriter); var defaultCommand = commandProvider.DefaultCommand(); var optionsString = o.Any() ? " [options]" : String.Empty; if (defaultCommand != null) { w.WriteLine($"usage: {name}{optionsString} {SyntaxWithoutCommand(defaultCommand)}"); w.WriteLine(defaultCommand.Description); c = c.Except(new[] { defaultCommand }).OrderBy(_ => _.Name); } if (c.Count() > 1) { w.WriteLine(); w.WriteLine($"usage: {name}{optionsString} <command> [<args>]"); w.WriteLine("Run a command."); w.WriteLine(); w.WriteLine("Commands:"); Format(c.Select(_ => new { _.Syntax, _.Description })).Write(w); } if (o.Any()) { w.WriteLine(); w.WriteLine("Options:"); Format(o.Select(_ => new { _.Syntax, _.Description })).Write(w); } }