argparser

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 3 Imported by: 0

README

go-argparser

Release License Go Version

Free and open source argument parsing library for Go.

License: MIT

Documentation

Index

Constants

View Source
const MAJOR_VERSION = 0
View Source
const MINOR_VERSION = 2
View Source
const PATCH_VERSION = 0
View Source
const PRERELEASE_ID = ""

Variables

This section is empty.

Functions

func MakeVersionString added in v0.2.0

func MakeVersionString() string

Types

type ArgParser

type ArgParser interface {

	// Add a command
	AddCommand(name string) Operation

	// Add an operation
	AddOperation(short rune, long string) Operation

	// Parse the arguments
	Parse(args []string) error
}

Argument parser interface

func NewArgParser

func NewArgParser() ArgParser

type Operation

type Operation interface {

	// Add a boolean switch
	AddBooleanSwitch(short rune, long string) Operation

	// Add a boolean switch with only a long name
	AddLongBooleanSwitch(long string) Operation

	// Add an increment switch
	AddIncrementSwitch(short rune, long string) Operation

	// Add an increment switch with only a long name
	AddLongIncrementSwitch(long string) Operation

	// Add an data switch
	AddDataSwitch(short rune, long string) Operation

	// Add an data switch with only a long name
	AddLongDataSwitch(long string) Operation

	// Set the executor
	//
	// NOTE: There may be only one executor.
	// If you set the executor multiple times, only the latest update will be preserved.
	SetExecutor(e func(op Operation, args []string) error) Operation

	// Complete the configuration and go back to its parent
	Complete() ArgParser

	// Get regular boolean switches
	BooleanSwitches() map[string]bool

	// Get increment switches
	IncrementSwitches() map[string]uint

	// Get data switches
	DataSwitches() map[string]string

	// Get data that do not belong to any data switches
	Data() []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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