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
12bc0136
Commit
12bc0136
authored
Apr 04, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc: document command fields
parent
ef934e8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
+38
-5
command.go
command.go
+38
-5
No files found.
command.go
View file @
12bc0136
...
@@ -32,17 +32,40 @@ type PostRunMap map[PostRunType]func(Response, ResponseEmitter) error
...
@@ -32,17 +32,40 @@ type PostRunMap map[PostRunType]func(Response, ResponseEmitter) error
// Command is a runnable command, with input arguments and options (flags).
// Command is a runnable command, with input arguments and options (flags).
// It can also have Subcommands, to group units of work into sets.
// It can also have Subcommands, to group units of work into sets.
type
Command
struct
{
type
Command
struct
{
Options
[]
Option
// Options defines the flags accepted by the command. Flags on specified
// on parent commands are inherited by sub commands.
Options
[]
Option
// Arguments defines the positional arguments for the command. These
// arguments can be strings and/or files.
//
// The rules for valid arguments are as follows:
//
// 1. No required arguments may follow optional arguments.
// 2. There can be at most one STDIN argument.
// 3. There can be at most one variadic argument, and it must be last.
Arguments
[]
Argument
Arguments
[]
Argument
PreRun
func
(
req
*
Request
,
env
Environment
)
error
// PreRun is run before Run. When executing a command on a remote
// daemon, PreRun is always run in the local process.
PreRun
func
(
req
*
Request
,
env
Environment
)
error
// Run is the function that processes the request to generate a response.
// Run is the function that processes the request to generate a response.
// Note that when executing the command over the HTTP API you can only read
// Note that when executing the command over the HTTP API you can only read
// after writing when using multipart requests. The request body will not be
// after writing when using multipart requests. The request body will not be
// available for reading after the HTTP connection has been written to.
// available for reading after the HTTP connection has been written to.
Run
Function
Run
Function
PostRun
PostRunMap
// PostRun is run after Run, and can transform results returned by run.
// When executing a command on a remote daemon, PostRun is always run in
// the local process.
PostRun
PostRunMap
// Encoders encode results from Run (and/or PostRun) in the desired
// encoding.
Encoders
EncoderMap
Encoders
EncoderMap
// Helptext is the command's help text.
Helptext
HelpText
Helptext
HelpText
// External denotes that a command is actually an external binary.
// External denotes that a command is actually an external binary.
...
@@ -54,7 +77,17 @@ type Command struct {
...
@@ -54,7 +77,17 @@ type Command struct {
// the Run Function.
// the Run Function.
//
//
// ie. If command Run returns &Block{}, then Command.Type == &Block{}
// ie. If command Run returns &Block{}, then Command.Type == &Block{}
Type
interface
{}
Type
interface
{}
// Subcommands allow attaching sub commands to a command.
//
// Note: A command can specify both a Run function and Subcommands. If
// invoked with no arguments, or an argument that matches no
// sub commands, the Run function of the current command will be invoked.
//
// Take care when specifying both a Run function and Subcommands. A
// simple typo in a sub command will invoke the parent command and may
// end up returning a cryptic error to the user.
Subcommands
map
[
string
]
*
Command
Subcommands
map
[
string
]
*
Command
}
}
...
...
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