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

Improve pueue follow behaviour with a task that does not yet have logs #436

Closed
fluffysquirrels opened this issue May 21, 2023 · 2 comments · Fixed by #443
Closed

Improve pueue follow behaviour with a task that does not yet have logs #436

fluffysquirrels opened this issue May 21, 2023 · 2 comments · Fixed by #443
Labels
t: Feature A new feature that needs implementation

Comments

@fluffysquirrels
Copy link

fluffysquirrels commented May 21, 2023

A detailed description of the feature you would like to see added.

  1. I want pueue follow ${TASK_ID} to exit with code != 0 when it cannot find a task log with that ID.

These are the lines that would need to be changed:

Err(err) => {
println!("Failed to get log file handles: {err}");
return Ok(());
}

Ideally, these would also be implemented, but if change 1 above was done, these could be implemented in a wrapper script:

  1. If ${TASK_ID} is currently queued (but not yet running), follow would wait for ${TASK_ID} to start and then follow the logs as normal. (This behaviour could be optional)
  2. Add a new argument --follow to pueue add that automatically runs pueue follow ${TASK_ID} after the task is added.

Currently if the task log is not present, pueue follow will print a human-readable error message, but exit with code 0 (success).

Explain your usecase of the requested feature

I am adding a task from a script, and I want to follow the log output for that task.

Alternatives

As a workaround, my wrapper script would have to:

  • pueue add the task
  • pueue wait --status Running ${TASK_ID}
  • pueue follow ${TASK_ID}

Additional context

If you like the sound of these features, I can implement them and submit a PR. Let me know :)

@fluffysquirrels fluffysquirrels added the t: Feature A new feature that needs implementation label May 21, 2023
@Nukesor Nukesor mentioned this issue Jun 6, 2023
@Nukesor
Copy link
Owner

Nukesor commented Jun 6, 2023

Hey :)

I implemented points 1. and 2. in the linked PR.

  • If a task gets removed or doesn't exist in the first place, the exit code is now 1.
  • If a task exists but didn't start yet, the client will wait for the task to start/finish instead of immediately exiting.

I see how this is an obvious UX improvement.

I'll have to write a few tests for this, since there're a few edge-case scenarios that I want test coverage for, but as far as I can see, it seems to work as expected. Feel free to check the branch.

@Nukesor
Copy link
Owner

Nukesor commented Jun 6, 2023

I added some tests and I'm pretty confident that your requested change works as expected.

I'll go ahead and merge in the next few days, but it would be great if you could give this a test run.

@Nukesor Nukesor closed this as completed Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: Feature A new feature that needs implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants