electrikmilk / args-parser

Arguments and auto-generated usage package

Home Page:https://pkg.go.dev/github.com/electrikmilk/args-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

args-parser

Build & Test GoDoc

A simple arguments parser written in Go. Mainly here so I can easily use it in my other projects.

Register arguments

You can currently register options/flags, then check on if that flag was used and access its value if applicable.

args.Register(args.Argument{
        name: "arg",
        description: "My first argument",
})

Auto-generated usage information

args.PrintUsage()

Usage

Flags follow the UNIX rules of having one dash for single-letter versions of flags and double-dashed versions of flags with whole words. (e.g. -a --all). It doesn't technically matter though since it just trims dashes from the beginning of the argument.

Argument values proceed the flag with a = sign separating (e.g. -a=value --arg=value).

Then either check if the flag is being used or get its value.

args.Using("arg") // bool

args.Value("arg") // string

Does not yet support subcommands.

About

Arguments and auto-generated usage package

https://pkg.go.dev/github.com/electrikmilk/args-parser

License:MIT License


Languages

Language:Go 100.0%