cmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   string // git tag ...
	GitCommit string // git rev-parse --short HEAD
	GoVersion string // go version
	BuildTime string // when the executable was built
	OsArch    string // uname -s -m
)

set at compile time with

-ldflags="-X 'github.com/mmbros/quotes/cmd.Version=x.y.z' -X 'github.com/mmbros/quotes/cmd.GitCommit=...'"

Functions

func Execute

func Execute(stderr io.Writer) int

Execute is the main function

Types

type Config

type Config struct {
	Database string                 `json:"database,omitempty"`
	Workers  int                    `json:"workers,omitempty"`
	Proxy    string                 `json:"proxy,omitempty"`
	Proxies  map[string]string      `json:"proxies,omitempty"`
	Sources  map[string]*sourceItem `json:"sources,omitempty"`
	Isins    map[string]*isinItem   `json:"isins,omitempty"`
	Mode     string                 `json:"mode,omitempty"`
	// contains filtered or unexported fields
}

Config is ...

func NewConfig

func NewConfig(cfi *configfile.SourceInfo, flags *Flags, allSources []string) (*Config, error)

func (*Config) SourceIsinsList

func (cfg *Config) SourceIsinsList() []*quotes.SourceIsins

SourceIsinsList ... If no sources, returns a list with zero items (it does not returns nil). NOTE: it assumes all isins and sources are enabled

func (*Config) String

func (cfg *Config) String() string

String returns a json string representation of the Config.

type Flags

type Flags struct {
	// contains filtered or unexported fields
}

func NewFlags

func NewFlags(fullname string, flagsgroup flagsGroup) *Flags

func (*Flags) Appname

func (flags *Flags) Appname() string

Appname returns the app name from the fullname of the command

Example:

fullname = "app cmd sub-cmd sub-sub-cmd"
output   = "app"

func (*Flags) IsPassed

func (flags *Flags) IsPassed(names string) bool

IsPassed checks if the flag was passed in the command-line arguments. names is a string that contains the comma separated aliases of the flag.

func (*Flags) Output

func (flags *Flags) Output() io.Writer

func (*Flags) Parse

func (flags *Flags) Parse(arguments []string) error

func (*Flags) SetUsage

func (flags *Flags) SetUsage(format string, a ...interface{})

SetUsage set the usage function of the inner FlagSet

func (*Flags) Usage

func (flags *Flags) Usage()

Jump to

Keyboard shortcuts

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