cli

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	Init   Init   `kong:"cmd,help='Initialize the data stores and generate the encryption key.'"`
	Get    Get    `kong:"cmd,help='Get the value of a key.'"`
	Set    Set    `kong:"cmd,help='Set the value of a key.'"`
	Rm     Rm     `kong:"cmd,help='Delete a key.'"`
	Ls     Ls     `kong:"cmd,help='List keys.'"`
	Role   Role   `kong:"cmd,help='Manage roles.'"`
	Serve  Serve  `kong:"cmd,help='Start the web server.'"`
	User   User   `kong:"cmd,help='Manage users.'"`
	Invite Invite `kong:"cmd,help='Manage invitations for remote users.'"`
	Remote Remote `kong:"cmd,help='Manage remote Disco nodes.'"`

	Version kong.VersionFlag `kong:"help='Output Disco version and exit.'"`
	DataDir string           `kong:"default='${dataDir}',help='Directory to store Disco data in.'"`
	//nolint:lll
	EncryptionKey string `` /* 153-byte string literal not displayed */
	Log           struct {
		Level slog.Level `enum:"DEBUG,INFO,WARN,ERROR" default:"INFO" help:"Set the app logging level."`
	} `embed:"" prefix:"log-"`
	// contains filtered or unexported fields
}

CLI is the command line interface of disco.

func New

func New(dataDir, version string) (*CLI, error)

New initializes the command-line interface.

func (*CLI) Command

func (c *CLI) Command() string

Command returns the full path of the executed command.

func (*CLI) Execute

func (c *CLI) Execute(appCtx *actx.Context) error

Execute starts the command execution. Parse must be called before this method.

func (*CLI) Parse

func (c *CLI) Parse(args []string) error

Parse the given command line arguments. This method must be called before Execute.

type Get

type Get struct {
	Key string `arg:"" help:"The unique key associated with the value."`

	Namespace string `default:"default" help:"The namespace to retrieve the value from."`
	Remote    string `help:"The remote Disco node to retrieve the value from."`
}

The Get command retrieves and prints the value of a key.

func (*Get) Run

func (c *Get) Run(appCtx *actx.Context) error

Run the get command.

type Init

type Init struct{}

The Init command initializes the Disco data stores and generates a new encryption key.

func (*Init) Run

func (c *Init) Run(appCtx *actx.Context) error

Run the init command.

type Invite

type Invite struct {
	User struct {
		Name string        `arg:"" help:"The name of the user to invite."`
		TTL  time.Duration `default:"1h" help:"Time duration the invite is valid for."`
	} `kong:"cmd,help='Create a new invitation token for an existing user to access this Disco node remotely.'"`
	Ls struct {
		All bool `help:"Also include expired invites."`
	} `kong:"cmd,help='List invites.'"`
	Rm struct {
		UUID []string `arg:"" help:"Unique invite IDs. A short prefix can be specified as long as it's unique."`
	} `kong:"cmd,help='Delete one or more invites.'"`
	Update struct {
		UUID string         `arg:"" help:"The unique invite ID. A short prefix can be specified as long as it's unique."`
		TTL  *time.Duration `help:"Time duration the invite is valid for."`
	} `kong:"cmd,help='Update an invite to extend its validity period.'"`
}

The Invite command manages invitations for remote users.

func (*Invite) Run

func (c *Invite) Run(kctx *kong.Context, appCtx *actx.Context) error

Run the invite command.

type Ls

type Ls struct {
	KeyPrefix string `arg:"" optional:"" help:"An optional key prefix."`

	Namespace string `default:"default" help:"The namespace to retrieve the keys from.\n If '*' is specified, keys in all namespaces are listed. "`
	Remote    string `help:"The remote Disco node to retrieve key data from."`
}

The Ls command prints keys.

func (*Ls) Run

func (c *Ls) Run(appCtx *actx.Context) error

Run the ls command.

type Remote

type Remote struct {
	Add struct {
		Name    string `arg:"" help:"The unique name of the remote."`
		Address string `arg:"" help:"The remote address in 'host[:port]' format, where 'host' can be a DNS hostname or an IP address."`
		Token   string `arg:"" help:"The invitation token used for authentication, generated by the remote node."`
	} `kong:"cmd,help='Add a new remote node.'"`
	Ls struct {
	} `kong:"cmd,help='List remote nodes.'"`
	Rm struct {
		Name string `arg:"" help:"The unique name of the remote."`
	} `kong:"cmd,help='Delete a remote node.'"`
	Update struct {
		Name    string `arg:"" help:"The unique name of the remote."`
		Address string `arg:"" help:"The remote address in 'host[:port]' format, where 'host' can be a DNS hostname or an IP address."`
	} `kong:"cmd,help='Update a remote node.'"`
}

The Remote command manages remote Disco nodes.

func (*Remote) Run

func (r *Remote) Run(kctx *kong.Context, appCtx *actx.Context) error

Run the remote command.

type Rm

type Rm struct {
	Key       string `arg:"" help:"The key to delete."`
	Namespace string `default:"default" help:"The namespace to key exists in."`
}

The Rm command deletes a key.

func (*Rm) Run

func (c *Rm) Run(appCtx *actx.Context) error

Run the rm command.

type Role

type Role struct {
	Add struct {
		Name        string              `arg:"" help:"The unique name of the role."`
		Permissions []models.Permission `` /* 160-byte string literal not displayed */
	} `kong:"cmd,help='Add a new role.'"`
	Rm struct {
		Name  string `arg:"" help:"The unique name of the role."`
		Force bool   `help:"Remove role even if it's assigned to existing users."`
	} `kong:"cmd,help='Remove a role.'"`
	Update struct {
		Name        string              `arg:"" help:"The unique name of the role."`
		Permissions []models.Permission `` /* 232-byte string literal not displayed */
	} `kong:"cmd,help='Change the settings of a role.'"`
	Ls struct {
	} `kong:"cmd,help='List roles.'"`
}

The Role command manages roles.

func (*Role) Run

func (c *Role) Run(kctx *kong.Context, appCtx *actx.Context) error

Run the role command.

type Serve

type Serve struct {
	Address string `help:"[host]:port to listen on" default:":2020"`
}

Serve starts the web server.

func (*Serve) Run

func (s *Serve) Run(appCtx *actx.Context) error

Run the serve command.

type Set

type Set struct {
	Key   string `arg:"" help:"The unique key that identifies the value."`
	Value string `arg:"" help:"The value."`

	Namespace string `default:"default" help:"The namespace to store the value in."`
	Remote    string `help:"The remote Disco node to store the value in."`
}

The Set command stores the value of a key.

func (*Set) Run

func (c *Set) Run(appCtx *actx.Context) error

Run the set command.

type User

type User struct {
	Add struct {
		Name  string   `arg:"" help:"The unique name of the user."`
		Roles []string `help:"Names of roles to assign to this user."`
	} `kong:"cmd,help='Add a new user.'"`
	Rm struct {
		Name string `arg:"" help:"The unique name of the user."`
	} `kong:"cmd,help='Remove a user.'"`
	Update struct {
		Name  string   `arg:"" help:"The unique name of the user."`
		Roles []string `help:"Names of roles to assign to this user. \n Any existing roles will be removed and replaced with this set."`
	} `kong:"cmd,help='Update the configuration of a user.'"`
	Ls struct {
	} `kong:"cmd,help='List users.'"`
}

The User command manages users.

func (*User) Run

func (c *User) Run(kctx *kong.Context, appCtx *actx.Context) error

Run the user command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL