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

just-completion: "export def" -> "export extern" #860

Merged
merged 5 commits into from
Jul 2, 2024

Conversation

1adept
Copy link
Contributor

@1adept 1adept commented Jun 1, 2024

Changing "export def" to "export extern" to not shadow the original command as it would disallow anything not defined in the re-definition

There seem to be similar cases in completions for (naive search with "rg 'export def'")

  • mask
  • winget (exports some defs and some externs. So i dont know if those defs are actually additional functionality)
  • pnpm (only exports some 'nu-complete' defs)
  • pass (only exports some 'nu-complete' defs)

I don't feel comfortable changing those as i am not familiar with them.

"export def" hides the original command and throws errors when using unknown commands

There seem to be similar cases in completions for (naive search with "rg 'export def'")
- mask
- winget (exports some defs and some externs. So i dont know if those defs are actually additional functionality)
- pnpm (only exports some 'nu-complete' defs)
- pass (only exports some 'nu-complete' defs)

I dont feel comfortable changing those as i am not familiar with them.
@kubouch
Copy link
Contributor

kubouch commented Jun 1, 2024

extern do not support custom code block like def, it's only used to shadow an external. The fact that it accepts a block is a bug. See https://www.nushell.sh/book/externs.html how to use extern.

@1adept
Copy link
Contributor Author

1adept commented Jun 1, 2024

Sorry, if i wasn't clear. I am aware that def shadows the original definition. That is why i am making this pr.

I was questioning some of the other "export def" occurrences (especially in winget). To me it seemed like those should also use "extern" instead of "def" or shouldn't export their defs in the first place

@kubouch
Copy link
Contributor

kubouch commented Jun 2, 2024

If you want to use extern, you should remove the block { ... }. As-is in this PR, it's not a valid Nushell syntax anymore (despite the lack of a syntax error, but that's a bug). Seems like the custom code is not necessary, so extern should be fine. If custom code is necessary, to make the signature permissive, you can use def --wrapped.

Added all flags shown in '--help' and added 'nu-complete' where possible
@1adept
Copy link
Contributor Author

1adept commented Jun 2, 2024

Sorry, i misunderstood. I didn't realize that blocks are not allowed for extern. It should be fine now.
I also added the missing flags while i was at it

@kubouch kubouch merged commit 1f3dc8b into nushell:main Jul 2, 2024
1 check passed
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