util

package
v0.0.0-...-77b4c49 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const AppHelpTemplate = TextFormat + `{{$Green -}}
NAME:
	{{$green}}{{.Name}}{{if .Usage}} - {{.Usage}}{{end}}{{$Green}}

USAGE:
	{{$green}}{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}
	{{- if .VisibleFlags}} [global options]{{end}}{{if .Commands}} command [command options]{{end}}
	{{- if .ArgsUsage}} {{.ArgsUsage}}{{else}} [arguments...]{{end}}{{end}}{{$Yellow}}{{if .Version}}{{if not .HideVersion}}

VERSION:
	{{$yellow}}{{.Version}}{{end}}{{end}}{{$Yellow}}{{if .Description}}

DESCRIPTION:
	{{$yellow}}{{.Description}}{{end}}{{$Yellow}}{{if len .Authors}}

AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
	{{$yellow}}{{range $index, $author := .Authors}}{{if $index}}
	{{end}}{{$author}}{{end}}{{end}}{{$Blue}}{{if .VisibleCommands}}

COMMANDS:{{range .VisibleCategories}}{{if .Name}}

	{{.Name}}:{{range .VisibleCommands}}
	{{$Blue}}{{join .Names ", "}}{{"\t\t\t\t"}}{{$blue}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
	{{$Blue}}{{join .Names ", "}}{{"\t\t\t\t"}}{{$blue}}{{.Usage}}{{$plain}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}{{$Cyan}}

GLOBAL OPTIONS:
	{{range $index, $option := .VisibleFlags}}{{if $index}}
	{{end}}{{$cyan}}{{$option}}{{$plain}}{{end}}{{end}}{{$Green}}{{if .Copyright}}

COPYRIGHT:
	{{$green}}{{.Copyright}}{{end}}{{$plain}}
`
View Source
const CommandHelpTemplate = TextFormat + `{{$Green -}}
NAME:
	{{$green}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}}{{- if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{end}} - {{.Usage}}{{$Green}}

USAGE:
	{{$green}}{{if .UsageText}}{{.UsageText | nindent 2 | trim}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} 
	{{- if .ArgsUsage}} {{.ArgsUsage}}{{end}}{{end}}{{$Green}}{{if .Category}}

CATEGORY:
	{{$green}}{{.Category}}{{end}}{{$Blue}}{{if .Description}}

DESCRIPTION:
	{{$blue}}{{.Description}}{{end}}{{$Cyan}}{{if .VisibleFlags}}

OPTIONS:
	{{$cyan}}{{range .VisibleFlags}}{{.}}
	{{end}}{{end}}{{$plain}}
`
View Source
const SubcommandHelpTemplate = TextFormat + `{{$Green -}}
NAME:
	{{$green}}{{.HelpName}} - {{if .Description}}{{.Description}}{{else}}{{.Usage}}{{end}}{{$Green}}

USAGE:
	{{$green}}{{if .UsageText}}{{.UsageText | nindent 2 | trim}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}}
	{{- if .ArgsUsage}} {{.ArgsUsage}}{{else}} [arguments...]{{end}}{{end}}{{$Blue}}

COMMANDS:{{range .VisibleCategories}}{{if .Name}}

	{{.Name}}:{{range .VisibleCommands}}
	{{$Blue}}{{join .Names ", "}}{{$blue}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
	{{$Blue}}{{join .Names ", "}}{{$blue}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}{{$Cyan}}

OPTIONS:
	{{$cyan}}{{range .VisibleFlags}}{{.}}
	{{end}}{{end}}{{$plain}}
`
View Source
const TextFormat = `` /* 531-byte string literal not displayed */

TextFormat defines variables of style and colors.

Variables

This section is empty.

Functions

func ExpandFilePath

func ExpandFilePath(path string) string

ExpandFilePath expands the leading `~` to absolute path

func MaxInt

func MaxInt(a, b int) int

func UserHomeDir

func UserHomeDir() string

UserHomeDir returns the current user's home directory absolute path, which is usually represented as `~` in most shells

Types

type Stringify

type Stringify struct {
	Str string
}

func (Stringify) String

func (s Stringify) String() string

Jump to

Keyboard shortcuts

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