https://github.com/inozuma/flagger
golang flag structure parsing
https://github.com/inozuma/flagger
Last synced: over 1 year ago
JSON representation
golang flag structure parsing
- Host: GitHub
- URL: https://github.com/inozuma/flagger
- Owner: Inozuma
- Created: 2015-05-08T19:29:34.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-08T23:29:41.000Z (about 11 years ago)
- Last Synced: 2025-01-26T13:43:39.541Z (over 1 year 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()
```