https://github.com/gobwas/flagvar
Collection of useful flag.Value implementations.
https://github.com/gobwas/flagvar
Last synced: about 1 month ago
JSON representation
Collection of useful flag.Value implementations.
- Host: GitHub
- URL: https://github.com/gobwas/flagvar
- Owner: gobwas
- Created: 2019-12-10T13:32:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-11T13:18:29.000Z (almost 4 years ago)
- Last Synced: 2025-01-24T09:42:30.134Z (3 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flagvar
> A tiny library with collection of [`flag.Value`][flagValue] implementations
# Overview
This is a collection of different useful [flag.Value][flagValue]
implementations. Works good with [flagutil][flagutil] library.> Under development right now.
# Usage
Here is a simple program that reads a date from the flag and prints it as a
unix timestamp:```go
package mainimport (
"flag"
"time""github.com/gobwas/flagvar"
)func main() {
flags := flag.NewFlagSet("time", flag.ExitOnError)
var t time.Time
flags.Var(&flagvar.Time(&t, "02.01.2006"),
"date",
"time to print as a unix timestamp in form `dd.mm.yyyy`",
)
flags.Parse()fmt.Fprintln(os.Stdout, t.Unix())
}
```[flagValue]: https://golang.org/pkg/flag#FlagSet
[flagutil]: https://github.com/gobwas/flagutil