arg

package
v0.0.0-...-1c5bcc7 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MPL-2.0 Imports: 2 Imported by: 4

Documentation

Overview

Package arg is used to read command line flags of the application.

The SDS supports a Flag which is composed of name and optionally a value.

Flags() returns all flags EnvPaths() returns the env file paths. FlagExist(name) flag exists? ExtractFlagValue(flag) finds the flag and returns the value of it. ExtractFlagName(flag) returns the flag name. IsFlag(str) returns true if the given string has a prefix NewFlag(name string, values ...string) returns a new flag by its name FlagValue(name) returns the flag value

Index

Constants

View Source
const (
	Prefix = "--"
	Sep    = "="
)

Variables

This section is empty.

Functions

func EnvPaths

func EnvPaths() []string

EnvPaths any command line data that comes after the files are .env file paths Any arg for application without '--' prefix is considered to be path to the environment file.

func ExtractFlagName

func ExtractFlagName(flag string) string

ExtractFlagName returns the flag name. If the flag is prefixed, then it will be trimmed.

func ExtractFlagValue

func ExtractFlagValue(flag string) string

ExtractFlagValue Extracts the value of the arg if it exists.

func FlagExist

func FlagExist(name string) bool

FlagExist is given flag exists or not.

func FlagValue

func FlagValue(name string) string

func Flags

func Flags() []string

Flags returns the flags from application flags.

func IsFlag

func IsFlag(str string) bool

IsFlag returns true, if the given string contains a flag prefix

func NewFlag

func NewFlag(name string, values ...string) string

NewFlag creates a new flag with the given name and optionally with a value

Types

This section is empty.

Jump to

Keyboard shortcuts

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