Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-cmds
Commits
56c2ddad
Commit
56c2ddad
authored
Nov 12, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Added HelpText struct to organize different help text fields in Commands
parent
84f00147
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
command.go
command.go
+17
-2
No files found.
command.go
View file @
56c2ddad
...
...
@@ -19,6 +19,21 @@ type Function func(Request) (interface{}, error)
// (or an error on failure)
type
Marshaller
func
(
Response
)
([]
byte
,
error
)
// HelpText is a set of strings used to generate command help text. The help
// text follows formats similar to man pages, but not exactly the same.
type
HelpText
struct
{
// required
Tagline
string
// used in <cmd usage>
ShortDescription
string
// used in DESCRIPTION
// optional - whole section overrides
Usage
string
// overrides USAGE section
LongDescription
string
// overrides DESCRIPTION section
Options
string
// overrides OPTIONS section
Arguments
string
// overrides ARGUMENTS section
Subcommands
string
// overrides SUBCOMMANDS section
}
// TODO: check Argument definitions when creating a Command
// (might need to use a Command constructor)
// * make sure any variadic args are at the end
...
...
@@ -28,8 +43,7 @@ type Marshaller func(Response) ([]byte, error)
// Command is a runnable command, with input arguments and options (flags).
// It can also have Subcommands, to group units of work into sets.
type
Command
struct
{
// MAYBE_TODO: move all the text fields into a struct
// MAYBE_TODO: move these out of command and put them somewhere in commands/cli
// TODO: remove these fields after porting commands to HelpText struct
Description
string
Help
string
SubcommandHelp
string
...
...
@@ -40,6 +54,7 @@ type Command struct {
Arguments
[]
Argument
Run
Function
Marshallers
map
[
EncodingType
]
Marshaller
Helptext
HelpText
// Type describes the type of the output of the Command's Run Function.
// In precise terms, the value of Type is an instance of the return type of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment