quicli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Unlicense Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const QUICLI_ERROR_PREFIX = "quicli error: "

Variables

View Source
var AllAliases mapset.Set[string]

Functions

func Aliases added in v1.0.0

func Aliases(aliases ...string) (aliasesSet mapset.Set[string])

func Run added in v0.0.4

func Run(c Cli)

Run: run the application corresponding of the CLI given as parameter

Types

type Cli

type Cli struct {
	Usage       string
	Description string
	Flags       []Flag
	Function    Runner
	CheatSheet  []Example
	Subcommands []Subcommand
}

struct representing CLI

func (*Cli) Parse

func (c *Cli) Parse() (config Config)

Parse: parse the different flags and return the struct containing the flag values. This is the core of the library. All the logic is within

func (*Cli) PrintCheatSheet

func (c *Cli) PrintCheatSheet()

PrintCheatSheet: print the cheat sheet of the command

func (*Cli) Run added in v0.0.4

func (c *Cli) Run()

Run: parse the different flags and run the function of the cli. Users have to define it, this is the core/logic of their application

func (*Cli) RunWithSubcommand added in v0.0.5

func (c *Cli) RunWithSubcommand()

RunWithSubcommand: equivalent of Run function when cli has subcommand defined

type Config

type Config struct {
	Flags map[string]interface{}
	Args  []string
}

func Parse added in v0.0.4

func Parse(c Cli) (config Config)

Parse: parse the CLI given in parameter

func (Config) GetBoolFlag

func (c Config) GetBoolFlag(name string) bool

return the string value of a string flag

func (Config) GetIntFlag

func (c Config) GetIntFlag(name string) int

return the int value of an interger flag

func (Config) GetStringFlag

func (c Config) GetStringFlag(name string) string

return the string value of a string flag

type Example

type Example struct {
	Title       string
	CommandLine string
}

Cheat Sheet

type Examples

type Examples []Example

type Flag

type Flag struct {
	Name        string
	Description string
	//Default is use to determine the flag value type and must be defined
	Default           interface{}
	NoShortName       bool
	NotForRootCommand bool
	ForSubcommand     SubcommandSet
}

struct representing a cli flag

type Flags

type Flags []Flag

type Runner added in v0.0.4

type Runner func(Config)

type Subcommand added in v0.0.5

type Subcommand struct {
	Name        string
	Aliases     mapset.Set[string]
	Description string
	Function    Runner
}

Subcommand

type SubcommandSet added in v0.0.5

type SubcommandSet []string

type Subcommands added in v0.0.5

type Subcommands []Subcommand

Jump to

Keyboard shortcuts

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