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

Submodules should be groupable (or have their own group) #2243

Closed
FelixZY opened this issue Jul 13, 2024 · 6 comments
Closed

Submodules should be groupable (or have their own group) #2243

FelixZY opened this issue Jul 13, 2024 · 6 comments

Comments

@FelixZY
Copy link

FelixZY commented Jul 13, 2024

I've started grouping commands because that makes them easier to find and read. I'm also using submodules to group certain commands specific to e.g. database commands. However, when listing these using

# Show this help text
[group("General")]
help:
    @just --list --unsorted --justfile {{ justfile() }}

the submodules are simply appended to the grouped output, making it appear as if they are part of the last declared group:

Available recipes:
    [General]
    help                # Show this help text

    [Code Utils]
    format              # Reformat all source files
    lint                # Lint source files

    [Environment]
    chenv new_env       # CHange ENVironment
    genenv              # Generate a .env file based on secrets/{environment}. Set the `ENVIRONMENT` envvar to change environment.
    current_environment # Print the environment of the variables in the current .env file
    app ...             # Application commands
    auth ...            # Authentication module commands
    db ...              # Database management commands

At a minimum, I would expect the submodules to be grouped separately:

    [Environment]
    chenv new_env       # CHange ENVironment
    genenv              # Generate a .env file based on secrets/{environment}. Set the `ENVIRONMENT` envvar to change environment.
    current_environment # Print the environment of the variables in the current .env file

    app ...             # Application commands
    auth ...            # Authentication module commands
    db ...              # Database management commands

At best, I would like to be able to set custom groups for my submodules:

# Application commands
[group("General")]
mod app "src/app/.app.justfile"

# Authentication module commands
[group("Subcommands")]
mod auth "src/auth/.auth.justfile"

# Database management commands
[group("Subcommands")]
mod db "src/db/.db.justfile"
Available recipes:
    [General]
    help                # Show this help text
    app ...             # Application commands

    [Subcommands]
    auth ...            # Authentication module commands
    db ...              # Database management commands

    [Code Utils]
    format              # Reformat all source files
    lint                # Lint source files

    [Environment]
    chenv new_env       # CHange ENVironment
    genenv              # Generate a .env file based on secrets/{environment}. Set the `ENVIRONMENT` envvar to change environment.
    current_environment # Print the environment of the variables in the current .env file
@casey
Copy link
Owner

casey commented Jul 14, 2024

Thanks for trying out modules!

I think these would be good changes. I added a space before submodules in --list when groups are present in #2244.

Putting modules into groups is a larger change, since it involves modifying the parser to accept attributes on modules, but it seems like a good idea, if anyone wants to tackle it.

@FelixZY
Copy link
Author

FelixZY commented Jul 14, 2024

Awesome, thanks - as always - for the quick fix @casey !

@neunenak
Copy link
Contributor

I'm working on a PR #2247 that allows the doc attribute on modules; that has the parser changes necessary to make adding the group attribute on modules possible as well.

@jmwoliver
Copy link
Contributor

I have a potential fix for this in this PR: #2263. Feel free to review whenever you get the chance!

jmwoliver added a commit to jmwoliver/just that referenced this issue Jul 20, 2024
jmwoliver added a commit to jmwoliver/just that referenced this issue Jul 20, 2024
@jmwoliver
Copy link
Contributor

@casey Is there any documentation I can update in the README for #2263? I was looking at updating the Recipe Groups and Modules sections with examples for grouping modules, but wasn't sure if that was the way to go. Let me know what you prefer and I'm happy to update the docs.

@casey
Copy link
Owner

casey commented Jul 28, 2024

I just merged #2282, which adds some initial documentation to the attributes section, regarding which attributes apply to which types of items. Feel free to open another PR if you think further documentation would be helpful!

@casey casey closed this as completed Jul 28, 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

4 participants