Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/electrikmilk/args-parser
- Owner: electrikmilk
- License: mit
- Created: 2022-12-31T04:26:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-22T04:06:18.000Z (over 1 year ago)
- Last Synced: 2023-11-01T09:19:59.097Z (over 1 year ago)
- Topics: args, argument-handler, argument-parser, arguments, go, golang
- Language: Go
- Homepage: https://pkg.go.dev/github.com/electrikmilk/args-parser
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# args-parser
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") // boolargs.Value("arg") // string
```---
Does not _yet_ support subcommands.