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

Enhance pueue edit UX #553

Closed
pacien opened this issue Jul 20, 2024 · 4 comments
Closed

Enhance pueue edit UX #553

pacien opened this issue Jul 20, 2024 · 4 comments
Labels
s: Client This issue touches the pueue client t: Discussion

Comments

@pacien
Copy link
Contributor

pacien commented Jul 20, 2024

Hello, and thank you for this very useful program!

I often forget to pass some options when adding new tasks,
and find myself needing to edit those, often in batch.

The current edit sub-command opens an editor for each value to edit,
which is quite cumbersome when just wanting to replace a value,
especially for multiple tasks at once.

Therefore, I think it would be nice for the edit sub-command to:

  • accept mulitple task IDs at once, and
  • accept replacement values directly from the CLI,
    to be applied to all the specified tasks at once.

Current help text of the edit sub-command:

❯ pueue edit --help
Edit the command, path, label, or priority of a stashed or queued task.
By default only the command is edited.
Multiple properties can be added in one go.

Usage: pueue edit [OPTIONS] <TASK_ID>

Arguments:
  <TASK_ID>  The task's id

Options:
  -c, --command   Edit the task's command
  -p, --path      Edit the task's path
  -l, --label     Edit the task's label
  -o, --priority  Edit the task's priority
  -h, --help      Print help

Target help text with the suggested additions:

❯ pueue edit --help
Edit the command, path, label, or priority of a stashed or queued task(s).
Values specified in options are used as replacements.
When no option is specified, EDITOR is opened.

Usage: pueue edit [OPTIONS] [TASK_IDS]...

Arguments:
  [TASK_IDS]...  The task(s) id

Options:
  -c, --command <COMMAND>    Edit the task(s)' command
  -p, --path <PATH>          Edit the task(s)' path
  -l, --label <LABEL>        Edit the task(s)' label
  -o, --priority <PRIORITY>  Edit the task(s)' priority
  -h, --help                 Print help

When no replacement option is supplied on the CLI,
the default EDITOR can be used to edit the properties.

But instead of opening the EDITOR for each value for each task individually,
this could be done in a combined way in a single YAML or TOML file.

For example, running pueue edit 0 1 would open an EDITOR with:

[0]
command = "echo this is my first command"
path = "/home/user"
label =
priority = 0

[1]
command = "echo this is my second command"
path = "/home/user/whatever"
label =
priority = 5

Since the current edit sub-command is quite interactive,
these modificatinos shouldn't break existing automated user scripts.

@Nukesor
Copy link
Owner

Nukesor commented Jul 21, 2024

Thanks for the detailed feature request :)

I already thought about this some time ago, over here.

I would like to take some time to re-evaluate on which approach is the most user-friendly, but this'll have to wait for a bit :)

@Nukesor Nukesor changed the title [UX] CLI / edit: replacement values from CLI, and combined edition CLI / edit: replacement values from CLI, and combined edition Jul 22, 2024
@Nukesor Nukesor added f: Help wanted t: Enhancement Something that exists, but could be made better s: Client This issue touches the pueue client t: Discussion and removed f: Help wanted labels Jul 22, 2024
@Nukesor Nukesor changed the title CLI / edit: replacement values from CLI, and combined edition Enhance pueue edit UX Jul 22, 2024
@Nukesor Nukesor removed the t: Enhancement Something that exists, but could be made better label Nov 26, 2024
@Nukesor
Copy link
Owner

Nukesor commented Nov 26, 2024

So, I thought about this for quite some time and this problem is pretty tricky.

As users can theoretically start any valid shell syntax in any shell they like (as the shell is configurable), we have practically no guarantees on how the input will look like.

To keep this convenient, we must allow multi-line editing. Strings with "\n" inside of it aren't an option.
No structured data format i know of can properly handle this. All of them have some kind of reserved characters or other constraints that make them unfeasible.

So, after some discussions with friends and other people, we came up with the idea to instead of creating a temporary file, to rather create a temporary directory with a file for each property to add.

All modern editors have directory/file tree support, so users can simply select the files they're interested in and edit without any file format constraints.

I really like this solution as it is very simple and outsources the UI issue to the user's editor, which is a highly specialized tool for editing multiple files.

@Nukesor
Copy link
Owner

Nukesor commented Nov 26, 2024

This could then be expanded for multiple tasks, where we create subdirectories for each task to edit with the ID being the name of the subdirectory.

@fzyzcjy
Copy link
Contributor

fzyzcjy commented Dec 18, 2024

Hi thanks for the new feature!

Here is my naive thoughts: Maybe we can let user edit a YAML file. For example,

- command: "echo this is my first command"
  path: "/home/user"
  label: 
  priority: 0
- command: "echo this is my second command"
  path: "/home/user"
  label: 
  priority: 0

Or in TOML:

[[commands]]
command = "echo this is my first command"
path = "/home/user"
label = ""
priority = 0

[[commands]]
command = "echo this is my second command"
path = "/home/user"
label = ""
priority = 0

Pros:

  • Everything in one file, thus easy to quickly modify. For example, I use vim, and can very quickly move these tasks around (as they are just several lines of "code"). On the other hand, if it is a folder (or multi folders), then it is not very easy.

Extension:

  • It would be great to support more "declarative" ways. For example, if I add several new lines, then that will be treated as adding a task. If I delete some lines, then that is parsed as removing a task.

If we want to allow multiline edit without "\n" in it: YAML has nice multiline string support https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines. TOML also have https://toml.io/en/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: Client This issue touches the pueue client t: Discussion
Projects
None yet
Development

No branches or pull requests

3 participants