Skip to content

Rename main to script name when running scripts - #9948

Merged
sophiajt merged 2 commits into
nushell:mainfrom
sophiajt:script_main_rename
Aug 11, 2023
Merged

sophiajt merged 2 commits into
nushell:mainfrom
sophiajt:script_main_rename

Conversation

@sophiajt

@sophiajt sophiajt commented Aug 7, 2023 •

Copy link
Copy Markdown
Contributor

Description

This PR does three related changes:

  • Keeps the originally declared name in help outputs.
  • Updates the name of the commands called main in the user script to the name of the script.
  • Fixes the source of signature information in multiple places. This allows scripts to have more complete help output.

Combined, the above allow the user to see the script name in the help output of scripts, like so:

image

NOTE: You still declare and call the definition main, so from inside the script main is still the correct name. But multiple folks agreed that seeing main in the script help was confusing, so this PR changes that.

User-Facing Changes

One potential minor breaking change is that module renames will be shown as their originally defined name rather than the renamed name. I believe this to be a better default.

Tests + Formatting

After Submitting

@amtoine amtoine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think this is better, thanks @jntrnr

two little things 😋

One potential minor breaking change is that module renames will be shown as their originally defined name rather than the renamed name. I believe this to be a better default.

not sure i get what you mean by that, especially the "originally defined name" 😕

and also do you think we could have a little test for this to make sure a simple script has the right name?

@sophiajt

Copy link
Copy Markdown
Contributor Author

@amtoine - I'd add a test, but I think we'd have to add script testing first? I think right now we always test via nu -c.

We should definitely add it, though I'm not sure if it should block this PR.

@amtoine

amtoine commented Aug 11, 2023

Copy link
Copy Markdown
Member

I'd add a test, but I think we'd have to add script testing first? I think right now we always test via nu -c.

We should definitely add it, though I'm not sure if it should block this PR.

i proposed adding a test just to avoid forgetting about it later 😋

  • if we cannot do that right now, maybe just add an empty ignored test with a FIXME?
  • if it's possible, even imperfect, then i'd vote for adding it right now

either way, i agree this is not a strong blocker 😉

@sophiajt

Copy link
Copy Markdown
Contributor Author

I'm going to land and file an issue and point at this as motivation for integration tests. we'll need them for main arguments too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:mention Noted in "Hall of Fame" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants