cli

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfigPath string
View Source
var ErrConfigPathUnknown = errors.New("config file path unknown")
View Source
var Version = "was not built properly"

Version is set via compiler flags (see script/build.bash)

Functions

func MarshalConfig

func MarshalConfig(c *Config) ([]byte, error)

func NewRootCommand

func NewRootCommand(cli *CLI) *cobra.Command

Types

type CLI

type CLI struct {
	Token      string
	Endpoint   string
	Context    context.Context
	Config     *Config
	ConfigPath string

	RootCommand *cobra.Command
	// contains filtered or unexported fields
}

func NewCLI

func NewCLI() *CLI

func (*CLI) ActionProgress

func (c *CLI) ActionProgress(ctx context.Context, action *hcloud.Action) error

func (*CLI) Client

func (c *CLI) Client() *hcloud.Client

func (*CLI) ReadConfig

func (c *CLI) ReadConfig() error

func (*CLI) ReadEnv

func (c *CLI) ReadEnv()

func (*CLI) Terminal

func (c *CLI) Terminal() bool

Terminal returns whether the CLI is run in a terminal.

func (*CLI) WriteConfig

func (c *CLI) WriteConfig() error

type Config

type Config struct {
	Endpoint      string
	ActiveContext *ConfigContext
	Contexts      []*ConfigContext
}

func UnmarshalConfig

func UnmarshalConfig(data []byte) (*Config, error)

func (*Config) ContextByName

func (config *Config) ContextByName(name string) *ConfigContext

func (*Config) RemoveContext

func (config *Config) RemoveContext(context *ConfigContext)

type ConfigContext

type ConfigContext struct {
	Name  string
	Token string
}

type RawConfig

type RawConfig struct {
	ActiveContext string             `toml:"active_context,omitempty"`
	Contexts      []RawConfigContext `toml:"contexts"`
}

type RawConfigContext

type RawConfigContext struct {
	Name  string `toml:"name"`
	Token string `toml:"token"`
}

Source Files

Jump to

Keyboard shortcuts

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