pflagdate

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 1 Imported by: 0

README

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	date.Date
}

func (*Date) Set

func (d *Date) Set(value string) error

Set implements pflag.Value.Set().

func (*Date) String

func (d *Date) String() string

String implements pflag.Value.String(). Returns date formatted as time.DateOnly.

func (*Date) Type

func (*Date) Type() string

Type implements pflag.Value.Type(). Returns "Date".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL