public void Format(IEnumerable <CommandDefinition> commands) { if (commands.All(cd => cd.Category == CommandCategory.None)) { var fmt = new ListOutputFormatter(this, "Name", "Synopsis"); var records = from cmddef in commands orderby cmddef.Name select fmt.MakeRecord(cmddef.Name, cmddef.Description); fmt.OutputRecords(records); } else { var fmt = new ListOutputFormatter(this, "Name", "Category", "Synopsis"); var records = from cmddef in commands orderby cmddef.Category, cmddef.Name select fmt.MakeRecord(cmddef.Name, cmddef.Category, cmddef.Description); fmt.OutputRecords(records); } }
public void Format(IEnumerable<CommandDefinition> commands) { if (commands.All(cd => cd.Category == CommandCategory.None)) { var fmt = new ListOutputFormatter(this, "Name", "Synopsis"); var records = from cmddef in commands orderby cmddef.Name select fmt.MakeRecord(cmddef.Name, cmddef.Description); fmt.OutputRecords(records); } else { var fmt = new ListOutputFormatter(this, "Name", "Category", "Synopsis"); var records = from cmddef in commands orderby cmddef.Category, cmddef.Name select fmt.MakeRecord(cmddef.Name, cmddef.Category, cmddef.Description); fmt.OutputRecords(records); } }