flag

package module
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package flag provides a very minimal command line flag parser. Both short flags (-s) and long flags (--long) are supported. Short flags can be chained (-xvzf) and "--" is treated as the end of flags marker. Boolean and integer values have first-class support; strings values are intended to serve as a catch-all for anything else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(val *bool, short rune, long string, base bool, usage string)

Bool defines a bool flag with the specified short and/or long variants, base value, and usage text. The argument val points to where the value is stored.

func Int64 added in v0.2.0

func Int64(val *int64, short rune, long string, base int64, usage string)

Int64 defines an int64 flag with the specified short and/or long variants, base value, and usage text. The argument val points to where the value is stored.

func Parse

func Parse(firstFlag int) int

Parse parses the command line flags from os.Args[firstFlag:] and returns the index of the first non-flag command line argument. If present, "--" is treated as the end of flags marker and the index of the next argument is returned. If Parse encounters a flag that has not been defined PrintUsageAndExit will be called.

func PrintUsageAndExit

func PrintUsageAndExit()

PrintUsageAndExit prints usage text based on the defined flags and exits.

func String

func String(val *string, short rune, long string, base string, usage string)

String defines a string flag with the specified short and/or long variants, base value, and usage text. The argument val points to where the value is stored.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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