Skip to content

Latest commit

 

History

History
 
 

commandline

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Command Line

The commandline package provides utilities for creating an interactive shell command for a cli using the go-prompt package.

Usage

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)

Interactive Shell

The commandline package provides an interactive shell for the cli application. The shell can be started by running the run command:

$ example shell

Autocompletion

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.

Exiting

To exit the shell, you can type quit, q or exit.