zcli

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 19 Imported by: 4

Documentation

Overview

Package zcli quickly build cli applications

Index

Constants

This section is empty.

Variables

View Source
var (
	// BuildTime Build Time
	BuildTime = ""
	// BuildGoVersion Build Go Version
	BuildGoVersion = ""
	// BuildGitCommitID Build Git CommitID
	BuildGitCommitID = ""
	// Log cli logger
	Log *zlog.Logger
	// FirstParameter First Parameter
	FirstParameter = os.Args[0]

	Name         string
	Version      string
	HideHelp     bool
	EnableDetach bool
	HidePrompt   bool
	Lang         = defaultLang

	ShortValues = map[string]interface{}{}
)

Functions

func Add

func Add(name, description string, command Cmd) *cmdCont

Add registers a cmd for the provided subCommand name

func CheckErr added in v0.1.31

func CheckErr(err error, exit ...bool)

func Current added in v1.6.4

func Current() (interface{}, bool)

func Error

func Error(format string, v ...interface{})

func GetLangText added in v0.1.54

func GetLangText(key string, def ...string) string

func Help

func Help()

Help show help

func Input added in v1.5.2

func Input(problem string, required bool) (text string)

func Inputln added in v1.5.2

func Inputln(problem string, required bool) (text string)

func IsDoubleClickStartUp added in v0.1.30

func IsDoubleClickStartUp() bool

func LaunchService added in v0.1.31

func LaunchService(name string, description string, fn func(), config ...*daemon.Config) (daemon.ServiceIface, error)

LaunchService Launch Service

func LaunchServiceRun added in v0.1.31

func LaunchServiceRun(name string, description string, fn func(), config ...*daemon.Config) error

LaunchServiceRun Launch Service and run

func Parse added in v0.0.19

func Parse(arg ...[]string) (hasflag bool)

Parse Parse command line arguments

func Run

func Run(runFunc ...runFunc) (ok bool)

Run runnable

func SetLangText added in v0.1.54

func SetLangText(lang, key, value string)

func SetUnknownCommand

func SetUnknownCommand(fn func(_ string))

SetUnknownCommand set unknown command handle

func SetVar

func SetVar(name, usage string) *v

func SingleKillSignal added in v1.6.0

func SingleKillSignal() <-chan bool

func Start

func Start(runFunc ...runFunc)

Start app

Types

type Cmd

type Cmd interface {
	Flags(subcommand *Subcommand)
	Run(args []string)
}

Cmd represents a subCommand

type Subcommand

type Subcommand struct {
	CommandLine *flag.FlagSet
	Name        string
	Desc        string
	Supplement  string
	Parameter   string
	// contains filtered or unexported fields
}

Subcommand sub command

Jump to

Keyboard shortcuts

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