Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/electrikmilk/args-parser

Arguments and auto-generated usage package
https://github.com/electrikmilk/args-parser

args argument-handler argument-parser arguments go golang

Last synced: 29 days ago
JSON representation

Arguments and auto-generated usage package

Awesome Lists containing this project

README

        

# 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.

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

### Auto-generated usage information

```go
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.

```go
args.Using("arg") // bool

args.Value("arg") // string
```

---

Does not _yet_ support subcommands.