Skip to content

pflag-date implements a Golang pflag.Value interface for go-date

License

Notifications You must be signed in to change notification settings

gbarr/pflag-date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pflag-date

Go Reference codecov Go ReportCard golangci-lint

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.

Documentation

go get github.com/gbarr/pflag-date

https://pkg.go.dev/github.com/gbarr/pflag-date

Example

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

Credits and License

Copyright (c) 2024 Graham Barr.

Released under the MIT License, see LICENSE.

About

pflag-date implements a Golang pflag.Value interface for go-date

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages