Skip to content

Fix function name in root command comment #660

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

Merged
merged 1 commit into from
Aug 10, 2025
Merged

Conversation

DannyBen
Copy link
Member

@DannyBen DannyBen commented Aug 10, 2025

cc #659

The root command behaves slightly differently than other commands, in terms of naming.

Other commands - say download - have all their functions prefixed by the name of the command - download_command, download_usage etc.

The root command has a split behavior: The command function is named root_command, while other functions are prefixed by the CLI name - download_usage.

Due to this behavior, we cannot just update the Script::Command.function_name method:

def function_name
options['function'] || full_name.to_underscore
end

and instead, we have to address this particular case with a local template condition:

> echo "# The code you write here will be wrapped by a function named '{{ root_command? ? 'root' : function_name }}_command()'."

@DannyBen DannyBen added this to the 1.3.2 milestone Aug 10, 2025
@DannyBen DannyBen requested a review from meleu August 10, 2025 06:54
Copy link
Collaborator

@meleu meleu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed it's working as expected.

@DannyBen DannyBen merged commit 1905bcb into master Aug 10, 2025
7 checks passed
@DannyBen DannyBen deleted the fix/root-function-name branch August 10, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants