Skip to content

YMDFlag implements a Golang flag.Value interface for YYYYMMDD-specified dates, facilitating CLI argument handling of dates like -start-date=20210101

License

Notifications You must be signed in to change notification settings

neomantra/ymdflag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ymdflag

Units tests Coverage Status golangci-lint CodeQL Go ReportCard Go Reference

YMDFlag implements a Golang flag.Value interface for YYYYMMDD-specified dates. This facilitiates command-line argument handling of date parameters such -start-date=20210101.

Documentation

go get github.com/neomantra/ymdflag

https://pkg.go.dev/github.com/neomantra/ymdflag

Examples

There are examples in the examples/ directory. Here's a quick sketch:

package main

import (
	"github.com/neomantra/ymdflag"
	"github.com/spf13/pflag"
)

func main() {
	var ymd ymdflag.YMDFlag
	pflag.VarP(&ymd, "date", "d", "YYYYMMDD date; defaults to today in local time")
	pflag.Parse()
	println("time of date:", ymd.AsTime().String())
}

Credits and License

Copyright (c) 2022-2023 Neomantra BV. Authored by Evan Wies.

Released under the MIT License, see LICENSE.txt.

About

YMDFlag implements a Golang flag.Value interface for YYYYMMDD-specified dates, facilitating CLI argument handling of dates like -start-date=20210101

Topics

Resources

License

Stars

Watchers

Forks

Languages