Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inozuma/flagger
golang flag structure parsing
https://github.com/inozuma/flagger
Last synced: 24 days ago
JSON representation
golang flag structure parsing
- Host: GitHub
- URL: https://github.com/inozuma/flagger
- Owner: Inozuma
- Created: 2015-05-08T19:29:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-08T23:29:41.000Z (over 9 years ago)
- Last Synced: 2024-06-20T16:49:17.240Z (5 months ago)
- Language: Go
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flagger
`flagger` is a simple package wrapping `flag` standard package allowing the declaration of flags via a structure.# Installation
```
go get -u github.com/inozuma/flagger
```# Usage
## Simple usage
Supposing we have a `Configuration`:
```go
type Configuration struct {
Enable bool `flag:"enable,false,enable something"`
Address string `flag:"addr,:8080,address to something"`
}
```You can call `flagger.Flag` to declare the flag `enable`:
```go
config := &Configuration{}if err := flagger.Flag(config); err != nil {
panic(err)
}
```And like `flag`, parse your flags with `flag.Parse`:
```go
flag.Parse()
```