standard library: implement help commands with $nu#8505
standard library: implement help commands with $nu#8505kubouch merged 46 commits intonushell:mainfrom
help commands with $nu#8505Conversation
By header i mean the green text that appears as a section name. e.g. the "search terms" in "Search terms: load, read, load_file, read_file" when running ``` help open | lines | get 2 ```
- `module-not-found-error` is the error message wrapper - `show-module` is the function that shows a single module doc - `help modules` is designed as a clone of the built-in `help modules`
I've simply copy the table given by `help operators` and kept the same logic as before.
They do not sarch usages.
This is almost a perfect copy-paste from the [`print_help.nu` gist from @jntrnr](https://gist.github.com/jntrnr/bb7f8827db14131ab95229e1c1efcc42).
…dard-library This commit solves the merge conflict for nushell#8505. The conflict has been solved such that the new `help ...` commands are appended to `std.nu`.
|
there it is finally 🎉 i'd love some feedback on that 😋 my main concerns
|
oh yeah good catch 👍 fixed in 6f7c7a1 👍
|
|
@fdncred i think i've answered to everything 😌 |
|
Related to but i think the signatures would need to be updated. Something weird is going on with signatures here recently. Note the signature in the later are like |
with this, we gain the highlight but, as i said, we not only search the name, usage and search terms 🤔
oh yeah you're right 🤔 |
I definitely want highlighting and maybe a flag to turn it off. If we don't do it with find we'll need to do it manually by finding the index-of and str replace. It will probably be slow, but I'd prefer to have identical output of what we have now.
I'm not sure that's stored anywhere right now just like this. You'd have to If we're trying to exactly match |
okey, i add that back 👍
mm we do not have this kind of output with the new
outside of this PR, right? |
|
I think we need to document the differences between the stdlib help and rust help. I'm pushing to have them be identical in functionality, but others may disagree. In my mind, if they're not identical, then we have a regression in functionality. Here's what I know is different so far.
|
|
@fdncred
|
|
ok, let's make this draft to show it's still a work in progress. |
👍 |
| let commands_string = ( | ||
| $module.commands | ||
| | each {|command| | ||
| $"($command) (char lparen)(ansi cyan_bold)($module.name) ($command)(ansi reset)(char rparen)" |
There was a problem hiding this comment.
This one is not correct. I think it's better to drop the cyan version for now because I don't think there is a way to query it correctly from inside Nushell.
The bold cyan shows the actual name of the exported command inside the current scope which depends on how you import it. use std will have std prefix while use std * won't. Later, we might support renaming of modules which would lead to a completely different prefix. We'd probably need to expose the ID of commands inside $nu in order to be able to link the module's command with an existing symbol in the current scope.
| print $"This module (ansi cyan)does not export(ansi reset) environment." | ||
| } else { | ||
| print $"This module (ansi cyan)exports(ansi reset) environment." | ||
| view source $module.env_block | nu-highlight |
There was a problem hiding this comment.
This one currently shows as a huge red blob. Prepending export-env before the block should fix it. Although I'm thinking if the export-env block is too big, it might be quite annoying (see https://github.com/pypa/virtualenv/blob/main/src/virtualenv/activation/nushell/activate.nu, for example), we can just leave it out as well. You can use view source module-name to view the source code if you want.
There was a problem hiding this comment.
mm you are rigth
use crates/nu-utils/standard_library/std.nu 'help modules'
help modules stdgives a red blob 🤔
this was causing "red blob" problems.
|
Oops, sorry, I misclicked. Looks good to me. It might need some touches but we can improve it as we go. For example, I personally wouldn't show the |
This adds the `help` commands from nushell#8505 and the `assert skip` from nushell#8748.
the `help` command needs to be there... 👀... thanks to nushell#8505
Related to #8505. # Description as #8505 has been landed, this PR fixes the prelude TODO and uses the `help` commands from the standard library in the prelude. # User-Facing Changes can now access `std help ...` to use the `help` implementations from the standard library # Tests + Formatting ``` $nothing ``` # After Submitting ``` $nothing ```


Related to one task in #8311.
Description
this PR implements the built-in
helpcommands in the standard library using the$nuvariableas the only source to access information about the commands, aliases and modules.
this can be thought as a proof of concept and a replacement proposition in the long-run, as the
helpcommands are not performance-critical and might not require taking up compilation timeand space.
progress
help moduleshelp aliaseshelp externs$nuwith external flagshelp operators✔️might require augmenting=> done in 55350c1$nuwith the table of operatorshelp commandshelp✔️can not find a way to implement that...=> done ina387256b4453cd8c04c28dce002e301da7d06157..62cf425efd8d5907115b5fc7f17ecccfe3c2763edetails
the error system
the
*-not-found-errorare here as convenience wrappers to throw all required errors, i.e. whena user parameter does not correspond to any commands, alias or module.
the actual
helpcommandsthe implemented
helpcommands follow the same structureprint-help-headerto print the section names in thehelpmessagesshow-*command that takes the command, alias or module information in the form of arecord and prints as much as possible in the same format as the built-ins
help *each having the same signature and behaviour--findis used, matches the name against the pattern--findis not used but a name is still provided, show it or throw a*-not-found-errorUser-Facing Changes
users can now access the
helpcommands viause std.nuand not rely on the builtins anymore.Tests + Formatting
i do not really know what to write here...
should i take a few know commands and compare the outputs of the
helpon them?After Submitting
i'd say probably part of the standard library announcement 👍