pflag-date
implements a Golang pflag.Value
interface for YYYY-MM-DD
-specified dates.
Combining github.com/spf13/pflag with github.com/hardfinhq/go-date.
This facilitiates command-line argument handling of date parameters such --start-date=2024-10-01
.
go get github.com/gbarr/pflag-date
https://pkg.go.dev/github.com/gbarr/pflag-date
package main
import (
"fmt"
pfdate "github.com/gbarr/pflag-date"
"github.com/spf13/pflag"
)
func main() {
var dt pfdate.Date
pflag.VarP(&dt, "start-date", "d", "YYYY-MM-DD date")
pflag.Parse()
fmt.Println("date:", dt.String())
}
Copyright (c) 2024 Graham Barr.
Released under the MIT License, see LICENSE.