private static IEnumerable <IRenderable> GetUsage(CommandModel model, CommandInfo?command) { var composer = new Composer(); composer.Style("yellow", "USAGE:").LineBreak(); composer.Tab().Text(model.GetApplicationName()); var parameters = new List <string>(); if (command == null) { parameters.Add("[grey][[OPTIONS]][/]"); parameters.Add("[aqua]<COMMAND>[/]"); } else { foreach (var current in command.Flatten()) { var isCurrent = current == command; if (!current.IsDefaultCommand) { if (isCurrent) { parameters.Add($"[underline]{current.Name.EscapeMarkup()}[/]"); } else { parameters.Add($"{current.Name.EscapeMarkup()}"); } } if (current.Parameters.OfType <CommandArgument>().Any()) { if (isCurrent) { foreach (var argument in current.Parameters.OfType <CommandArgument>() .Where(a => a.Required).OrderBy(a => a.Position).ToArray()) { parameters.Add($"[aqua]<{argument.Value.EscapeMarkup()}>[/]"); } } var optionalArguments = current.Parameters.OfType <CommandArgument>().Where(x => !x.Required).ToArray(); if (optionalArguments.Length > 0 || !isCurrent) { foreach (var optionalArgument in optionalArguments) { parameters.Add($"[silver][[{optionalArgument.Value.EscapeMarkup()}]][/]"); } } } if (isCurrent) { parameters.Add("[grey][[OPTIONS]][/]"); } } if (command.IsBranch) { parameters.Add("[aqua]<COMMAND>[/]"); } } composer.Join(" ", parameters); composer.LineBreaks(2); return(new[] { composer, }); }