flags

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Overview

Package flag provides command line flag

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](flagName string) T

Get is get the command line flags value.

ex) value := flags.Get[int]("int")

func Parse

func Parse(flagInfos []FlagInfo) error

Parse is parse the command line flags.

ex) err := flags.Parse([]flags.FlagInfo{
		{FlagName: "bool", Usage: "bool usage", DefaultValue: true},
		{FlagName: "time.Duration", Usage: "time.Duration usage (default 0h0m0s0ms0us0ns)", DefaultValue: time.Duration(0) * time.Second},
		{FlagName: "float64", Usage: "float64 usage (default 0)", DefaultValue: float64(0)},
		{FlagName: "int64", Usage: "int64 usage (default 0)", DefaultValue: int64(0)},
		{FlagName: "int", Usage: "int usage (default 0)", DefaultValue: int(0)},
		{FlagName: "string", Usage: "string usage (default \"\")", DefaultValue: string("")},
		{FlagName: "uint64", Usage: "uint64 usage (default 0)", DefaultValue: uint64(0)},
		{FlagName: "uint", Usage: "uint usage (default 0)", DefaultValue: uint(0)},
	})

Types

type FlagInfo

type FlagInfo struct {
	FlagName     string
	Usage        string
	DefaultValue any
	// contains filtered or unexported fields
}

FlagInfo is a struct that has command line flags information.

Jump to

Keyboard shortcuts

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