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

Print timestamps when --timestamps is passed #2084

Merged
merged 11 commits into from
May 29, 2024
Merged

Conversation

neunenak
Copy link
Contributor

Print timestamps when the --timestamps flag is passed

#2078

@neunenak
Copy link
Contributor Author

Thought I'd take a crack at #2078 .

recipe:
    echo "ONE"
    sleep 10
    echo "TWO"
$ just --timestamps
[2024-05-25T07:41:28.376232233+00:00] echo "ONE"
ONE
[2024-05-25T07:41:28.377825276+00:00] sleep 10
[2024-05-25T07:41:38.380184613+00:00] echo "TWO"
TWO

A couple of questions:

  • this feature doesn't seem all that useful unless there's a way to configure the format/time zone/etc. of the printed timestamp. The above is just printing the default chrono ISO8601 formatted timestamp. I'm not sure what the best way to configure this is - another option --timestamp-format <format-string> that gets passed directly into chrono? Have --timestamp accept an optional format string argument? something else?

  • this could take the short argument -t, but I'm not sure if it's worth burning that single character on this as opposed to some other more useful option that could start with t

@casey
Copy link
Owner

casey commented May 25, 2024

  • this feature doesn't seem all that useful unless there's a way to configure the format/time zone/etc. of the printed timestamp. The above is just printing the default chrono ISO8601 formatted timestamp. I'm not sure what the best way to configure this is - another option --timestamp-format <format-string> that gets passed directly into chrono? Have --timestamp accept an optional format string argument? something else?

Yah, agreed. The default formatting is super long. From the original issue, it sounds like the main thing that they wanted to know was how long each command took. We could consider using a default format that only prints the time, like 16:55, which would allow figuring out how long things took, and letting them pass --timestamp-format if they want to customize it. I don't think --timestamp can have an optional format argument, otherwise just --timestamp RECIPE would swallow the recipe.

I'd add --timestamp first and do --timestamp-format in a follow-up PR.

  • this could take the short argument -t, but I'm not sure if it's worth burning that single character on this as opposed to some other more useful option that could start with t

I'm always very stingy about short arguments, so I'd leave it out and wait for someone to complain that they use it a lot.

--timestamp should also be settable with an env var, i.e., JUST_TIMESTAMP.

@neunenak neunenak marked this pull request as ready for review May 28, 2024 04:02
@casey
Copy link
Owner

casey commented May 29, 2024

I removed subseconds from timestamps. My hunch is that this will be noisier for not much benefit. Timestamp output is human readable, so not covered by backwards compatibility guarantees, so we can add it back later if people want it.

@casey casey enabled auto-merge (squash) May 29, 2024 03:30
@casey casey merged commit d14aae1 into casey:master May 29, 2024
5 checks passed
@neunenak neunenak deleted the timestamps branch May 29, 2024 06:12
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

Successfully merging this pull request may close these issues.

2 participants