Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for durations #7

Closed
Backfighter opened this issue Mar 18, 2018 · 1 comment
Closed

No support for durations #7

Backfighter opened this issue Mar 18, 2018 · 1 comment

Comments

@Backfighter
Copy link

The checker interface doesn't allow storing and retrieving durations, which are often very useful especially for webapplications. Of course one could use an int to store durations, but if things like "m","h","days",... are interpreted it is way easier for the user to configure durations.

@paked
Copy link
Owner

paked commented Mar 18, 2018

Processing dates (and by extension times) is a bit of a complicated topic, and as far as I know there isn't really a standard way of representing them in a CLI.

I don't really see much of an advantage to adding them in as first class citizens compared to using the normal string interface, and then getting a time object via time.Parse. Something like the following would work:

  1. You'll pass an input `./cli --date="2018-03-18"
  2. You get it as a string: date := conf.String("date", "2012-12-21", "a date... for something") (and then call conf.Parse() somewhere as usual).
  3. You parse that date into an actual time (t, _ = time.Parse("2006-01-02", date))
  4. ???
  5. Profit!

I'm going to go ahead and close this issue, but feel free to re-open it if If you want to keep the discussion going :)

edit: and if you specifically want durations, the time package has you covered on that too I think. The parse function is a magical thing.

@paked paked closed this as completed Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants