command

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package command 提供控制台操作功能,如选项/参数读取。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsOpt

func ContainsOpt(name string) bool

ContainsOpt 检查选项名 `name` 是否存在于参数中。

func GetArg

func GetArg(index int, def ...string) string

GetArg 返回位于 `index` 索引处的参数。

func GetArgAll

func GetArgAll() []string

GetArgAll 返回所有已解析的参数。

func GetOpt

func GetOpt(name string, def ...string) string

GetOpt返回名为`name`的选项值。

func GetOptAll

func GetOptAll() map[string]string

GetOptAll 返回所有已解析的选项。

func GetOptWithEnv

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

GetOptWithEnv returns the command line argument of the specified `key`. If the argument does not exist, then it returns the environment variable with specified `key`. It returns the default value `def` if none of them exists.

Fetching Rules: 1. Command line arguments are in lowercase format, eg: gf.package.variable; 2. Environment arguments are in uppercase format, eg: GF_PACKAGE_VARIABLE;

func Init

func Init(args ...string)

Init 进行自定义初始化。

func ParseUsingDefaultAlgorithm

func ParseUsingDefaultAlgorithm(args ...string) (parsedArgs []string, parsedOptions map[string]string)

使用默认算法解析参数。

Types

This section is empty.

Jump to

Keyboard shortcuts

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