cli

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package cli provides common code for building a command line control for the service

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadStdin

func ReadStdin(filename string) ([]byte, error)

ReadStdin reads from stdin if the file is "-"

func WriteFile

func WriteFile(filespec string, contents []byte, perms os.FileMode) error

WriteFile creates and writes to a file

Types

type Cli

type Cli struct {
	*ctl.Ctl
	ReadFileOrStdin ReadFileOrStdinFn
	// contains filtered or unexported fields
}

Cli is a project specific wrapper to the ctl.Cli struct

func New

func New(d *ctl.ControlDefinition) *Cli

New creates an instance of CLI

func (*Cli) CryptoProv

func (cli *Cli) CryptoProv() *cryptoprov.Crypto

CryptoProv returns crypto provider

func (*Cli) EnsureCryptoProvider

func (cli *Cli) EnsureCryptoProvider() error

EnsureCryptoProvider is pre-action to load Crypto provider

func (*Cli) PopulateControl added in v0.4.0

func (cli *Cli) PopulateControl() error

PopulateControl is a pre-action for kingpin library to populate the control object after all the flags are parsed

func (*Cli) PrintCert

func (cli *Cli) PrintCert(key, csrBytes, cert []byte)

PrintCert outputs a cert, key and csr to stdout

func (*Cli) RegisterAction

func (cli *Cli) RegisterAction(f func(c ctl.Control, flags interface{}) error, params interface{}) ctl.Action

RegisterAction create new Control action

func (*Cli) Verbose added in v0.4.0

func (cli *Cli) Verbose() bool

Verbose specifies if verbose output is enabled

func (*Cli) WithCryptoProvider added in v0.4.0

func (cli *Cli) WithCryptoProvider(crypto *cryptoprov.Crypto)

WithCryptoProvider sets custom Crypto Provider

type ReadFileOrStdinFn added in v0.4.0

type ReadFileOrStdinFn func(filename string) ([]byte, error)

ReadFileOrStdinFn allows to read from file or Stdin if the name is "-"

type ReturnCode

type ReturnCode ctl.ReturnCode

ReturnCode is the type that your command returns, these map to standard process return codes

Jump to

Keyboard shortcuts

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