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

More control over sorting of tasks #3447

Closed
davidolrik opened this issue Dec 10, 2024 · 4 comments
Closed

More control over sorting of tasks #3447

davidolrik opened this issue Dec 10, 2024 · 4 comments

Comments

@davidolrik
Copy link

I would like to be able to list all my tasks as they are defined in the .mise.toml file.

Or maybe even be able to give "sections" (task prefixes) a priority so I can pull specific task sections to the top, and then have whatever sort order the user specified applied to each section.

@jdx
Copy link
Owner

jdx commented Dec 10, 2024

I would like to be able to list all my tasks as they are defined in the .mise.toml file.

I don't think this is realistic. The list is a merge of all the config files and all the file tasks in the current directory. You'd hae no way to control the order of any of the other source. It would only work if you had a single config file and no file tasks.

Or maybe even be able to give "sections" (task prefixes) a priority so I can pull specific task sections to the top, and then have whatever sort order the user specified applied to each section.

we could just add a sort_group integer to each task:

[tasks.second]
run = '...'
sort_group = 1

[tasks.first]
run = '...'
sort_group = 0

@jdx
Copy link
Owner

jdx commented Dec 10, 2024

I will say this would probably not be easy to achieve. We'd need to switch from using BTreeMap to IndexMap then apply the sorting in all the places tasks are displayed (which is numerous)—or have a complex key in the BTreeMap but I kind of hate doing that. Given that, I think this is a jeff task that others probably wouldn't be able to achieve easily.

And given that, it's worth me mentioning I don't actually like this idea. I would not want to work in a project where the tasks weren't just all sorted alphabetically. So if you want to see it, unless you want to dive into what I'm sure would be some nasty rust, you'll need to convince me why it's important.

@davidolrik
Copy link
Author

I see the complexity of the merge, the only reason I can think of that would make it important would be to put certain tasks first in the list, like the most used ones - without having to prefix the task names with aaa or something like that.

I previously used just which has a --unsorted option that allows me to just display the tasks in "file order" so the most used tasks could be at the top of the list.

But I agree with you that sorting everthing alphabetically is a must, except for one or two tasks that I always want to be at the top of the list.

I like the sort_group that could work for me, and since we already have the --sort (?:name|alias|description|source) maybe that can be lumped in with those.

A solution could be to add a default sort_group of 0 to all tasks and any task with a sort_group with a higher number would be listed above those - the higher the number the higher the position, and then sorted alphabetically within the group.

@jdx
Copy link
Owner

jdx commented Dec 14, 2024

I'm going to close since I don't see this happening right now

@jdx jdx closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants