The commandline
package provides utilities for creating an interactive shell command for a cli
using the go-prompt
package.
To use the commandline
package, first import the package:
import "github.com/synapsecns/sanguine/core/commandline"
Then, create a new commandline.CommandLine
with the desired value type:
shellCommands := []*cli.Command{
{
Name: "example",
Usage: "example command",
Action: func(c *cli.Context) error {
return nil
},
}
}
app := &cli.App{
Name: "example",
Usage: "example interactive command line",
Commands: shellCommands,
}
shellCommand := commandline.GenerateShellCommand(shellCommands)
app.Commands = append(app.Commands, shellCommand)
The commandline
package provides an interactive shell for the cli
application. The shell can be started by running the run
command:
$ example shell
Autocompletion is supported for both commands and flags. To see the available commands, enter help. To see help
for a specific command, enter help .
Autocompletion for flags will only suggest flags that are valid for the current command. For example, if the current command is example
, then the flag --example
will be suggested, but not --example2
.
To exit the shell, you can type quit
, q
or exit
.