Skip to content

Commit

Permalink
Merge pull request #582 from Nukesor/edit-tasks
Browse files Browse the repository at this point in the history
change(edit): New way to edit tasks
  • Loading branch information
Nukesor authored Dec 1, 2024
2 parents 5738fc9 + 1cb7d5a commit d43beef
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 417 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ The new state design resolves this issue by allowing Pueue to manipulate subproc

TLDR: Commands that start/stop/kill/pause tasks now only return when the task is actually started/stopped/killed/paused.

### New editing

Task editing was a bit tedious until recently.
One could only edit a single task at a time and you had to specify which properties you wanted to add.
Each property was then opened in a new `$EDITOR` session, which meant that users had to open and close editors up to four times to edit a single task.

After a lot of consideration, a new way of editing tasks has been designed that allows simple and convenient editing of multiple tasks at once.
For this, a temporary directory is created for every task to edit and a new file for every property, resulting in the following structure:

```
📁 0/
│ * command
│ * label
│ * path
└ * priority
```

You can then just navigate the resulting file structure and edit the properties you want in the editor of your choice.

I'm aware that this might not be for everyone, so feedback is very much encouraged over [here](https://github.com/Nukesor/pueue/issues/553).

### Runtime invariants

Previously, various task-state related invariants were enforced during runtime. For example, a `Queued` task should not have a `start` or `enqueued_at` time set.
Expand All @@ -46,6 +67,7 @@ TLDR: The new task state representation is more verbose but significantly cleane
- Send log output to `stderr` instead of `stdout` [#562](https://github.com/Nukesor/pueue/issues/562).
- Change default log level from error to warning [#562](https://github.com/Nukesor/pueue/issues/562).
- Bumped MSRV to 1.70.
- **Breaking**: Redesigned task editing process [#553](https://github.com/Nukesor/pueue/issues/553).

### Add

Expand Down
1 change: 1 addition & 0 deletions pueue/src/bin/pueued.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ fn fork_daemon(opt: &CliArguments) -> Result<()> {
command.creation_flags(CREATE_NO_WINDOW);
}

#[allow(clippy::zombie_processes)]
command
.args(&arguments)
.spawn()
Expand Down
42 changes: 6 additions & 36 deletions pueue/src/client/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,9 @@ pub enum SubCommand {
#[arg(long)]
not_in_place: bool,

/// Edit the tasks' commands before restarting.
/// Edit the task before restarting.
#[arg(short, long)]
edit: bool,

/// Edit the tasks' paths before restarting.
#[arg(short = 'p', long)]
edit_path: bool,

/// Edit the tasks' labels before restarting.
#[arg(short = 'l', long)]
edit_label: bool,

/// Edit the tasks' priorities before restarting.
#[arg(short = 'o', long)]
edit_priority: bool,
},

#[command(about = "Either pause running tasks or specific groups of tasks.\n\
Expand Down Expand Up @@ -282,30 +270,12 @@ pub enum SubCommand {
input: String,
},

#[command(
about = "Edit the command, path, label, or priority of a stashed or queued task.\n\
By default only the command is edited.\n\
Multiple properties can be added in one go."
)]
#[command(about = "Adjust editable properties of a task.\n\
A temporary folder folder will be opened by your $EDITOR, which contains \n\
a file for each editable property.")]
Edit {
/// The task's id.
task_id: usize,

/// Edit the task's command.
#[arg(short, long)]
command: bool,

/// Edit the task's path.
#[arg(short, long)]
path: bool,

/// Edit the task's label.
#[arg(short, long)]
label: bool,

/// Edit the task's priority.
#[arg(short = 'o', long)]
priority: bool,
/// The ids of all tasks that should be edited.
task_ids: Vec<usize>,
},

#[command(about = "Use this to add or remove groups.\n\
Expand Down
25 changes: 2 additions & 23 deletions pueue/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,8 @@ impl Client {
Ok(false)
}

SubCommand::Edit {
task_id,
command,
path,
label,
priority,
} => {
let message = edit(
&mut self.stream,
&self.settings,
*task_id,
*command,
*path,
*label,
*priority,
)
.await?;
SubCommand::Edit { task_ids } => {
let message = edit(&mut self.stream, &self.settings, task_ids).await?;
self.handle_response(message)?;
Ok(true)
}
Expand All @@ -243,9 +228,6 @@ impl Client {
in_place,
not_in_place,
edit,
edit_path,
edit_label,
edit_priority,
} => {
// `not_in_place` superseeds both other configs
let in_place =
Expand All @@ -260,9 +242,6 @@ impl Client {
*stashed,
in_place,
*edit,
*edit_path,
*edit_label,
*edit_priority,
)
.await?;
Ok(true)
Expand Down
Loading

0 comments on commit d43beef

Please sign in to comment.