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

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.

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)
}
```