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

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.

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 main

import (
"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