https://github.com/ckaznocha/gflag
A go1.18 wrapper to provide a simple generics based API for defining command line flags.
https://github.com/ckaznocha/gflag
flag flags flagset generics go golang
Last synced: 9 months ago
JSON representation
A go1.18 wrapper to provide a simple generics based API for defining command line flags.
- Host: GitHub
- URL: https://github.com/ckaznocha/gflag
- Owner: ckaznocha
- License: mit
- Created: 2021-12-19T23:41:02.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-19T23:45:26.000Z (over 4 years ago)
- Last Synced: 2025-02-08T14:13:36.660Z (over 1 year ago)
- Topics: flag, flags, flagset, generics, go, golang
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gflag
A go1.18 wrapper to provide simple generics based API for defining command line flags.
## Example
```
package main
import (
"flag"
"fmt"
"time"
"github.com/ckaznocha/gflag"
)
func main() {
salutation := gflag.Define("salutation", "Hello", "a salutation")
subject := gflag.Define("subject", "user", "a subject to greet")
wait := gflag.Define("wait", 1*time.Second, "how long to wait before greeting")
flag.Parse()
time.Sleep(*wait)
fmt.Printf("%s, %s\n", *salutation, *subject)
}
```