forked from OpenWrap/openwrap
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issue-83-sort-command-list' of http://github.com/andrew…
- Loading branch information
Showing
4 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace OpenWrap.Commands.Core | ||
{ | ||
public class CommandGroupResult : Success | ||
{ | ||
readonly string _noun; | ||
readonly ICommandDescriptor[] _commands; | ||
|
||
public CommandGroupResult(string noun, IEnumerable<ICommandDescriptor> commands) | ||
{ | ||
_noun = noun; | ||
_commands = commands.OrderBy(c => c.Verb).ToArray(); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
var builder = new StringBuilder(); | ||
builder.AppendLine(_noun); | ||
foreach (var command in _commands) | ||
{ | ||
builder.Append(" ").Append(command.Verb).Append(": ").AppendLine(command.Description); | ||
} | ||
return builder.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters