cli

package
v0.0.0-...-be30e72 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: Apache-2.0 Imports: 16 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 {
	AlbumTitle       string   `short:"a" long:"album" value-name:"TITLE" description:"Add files to the album or a new album if it does not exist"`
	NewAlbum         string   `short:"n" long:"new-album" value-name:"TITLE" description:"Add files to a new album"`
	RequestHeaders   []string `long:"request-header" value-name:"KEY:VALUE" description:"Add the header on fetching URLs"`
	RequestBasicAuth string   `long:"request-auth" value-name:"USER:PASS" description:"Add the basic auth header on fetching URLs"`

	ConfigName string `long:"gpupconfig" env:"GPUPCONFIG" default:"~/.gpupconfig" description:"Path to the config file"`
	Debug      bool   `long:"debug" env:"DEBUG" description:"Enable request and response logging"`

	ExternalConfig ExternalConfig `group:"Options read from gpupconfig"`

	Paths []string
}

CLI represents input for the command.

func New

func New(osArgs []string, version string) (*CLI, error)

New creates a new CLI object.

This does the followings: - Determine path to the config - Read the config - Parse the arguments - Validate

If the config is invalid, it will be ignored.

func (*CLI) Run

func (c *CLI) Run(ctx context.Context) error

Run runs the command.

type EncodedToken

type EncodedToken string

EncodedToken is a base64 encoded json of token.

func EncodeToken

func EncodeToken(token *oauth2.Token) (EncodedToken, error)

EncodeToken returns an EncodedToken.

func (EncodedToken) Decode

func (t EncodedToken) Decode() (*oauth2.Token, error)

Decode returns the token object.

type ExternalConfig

type ExternalConfig struct {
	ClientID     string       `yaml:"client-id" long:"google-client-id" env:"GOOGLE_CLIENT_ID" description:"Google API client ID"`
	ClientSecret string       `yaml:"client-secret" long:"google-client-secret" env:"GOOGLE_CLIENT_SECRET" description:"Google API client secret"`
	EncodedToken EncodedToken `yaml:"token" long:"google-token" env:"GOOGLE_TOKEN" description:"Google API token"`
}

ExternalConfig represents items in gpupconfig.

func (*ExternalConfig) Read

func (c *ExternalConfig) Read(name string) error

Read parses the YAML file.

func (*ExternalConfig) Write

func (c *ExternalConfig) Write(name string) error

Write writes the items to the YAML file.

Jump to

Keyboard shortcuts

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