openaq / openaq-cli

OpenAQ command line interface
MIT License
3 stars 0 forks source link

`measurements list` date error #1

Closed russbiggs closed 1 year ago

russbiggs commented 1 year ago

If an empty date string is passed to the --from flag the program panics and errors:

panic: parsing time "" as "2006-01-02": cannot parse "" as "2006"

goroutine 1 [running]:
github.com/openaq/openaq-cli/cmd/measurements.glob..func2(0x14000197500?, {0x1400010ff20?, 0x4?, 0x100b8ae60?})
    github.com/openaq/openaq-cli/cmd/measurements/measurements.go:107 +0x214
github.com/spf13/cobra.(*Command).execute(0x100fa5b60, {0x1400010fec0, 0x3, 0x3})
    github.com/spf13/cobra@v1.7.0/command.go:944 +0x640
github.com/spf13/cobra.(*Command).ExecuteC(0x100fa3bc0)
    github.com/spf13/cobra@v1.7.0/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.7.0/command.go:992
github.com/openaq/openaq-cli/cmd.Execute()
    github.com/openaq/openaq-cli/cmd/root.go:37 +0x24
main.main()
    github.com/openaq/openaq-cli/main.go:9 +0x1c

This could be solved with a default value.