Skip to content

Collapse some help commands columns into a single column#7052

Merged
rgwood merged 1 commit intonushell:mainfrom
dandavison:help-commands-command-type
Nov 10, 2022
Merged

Collapse some help commands columns into a single column#7052
rgwood merged 1 commit intonushell:mainfrom
dandavison:help-commands-command-type

Conversation

@dandavison
Copy link
Contributor

@dandavison dandavison commented Nov 8, 2022

This PR collapses the is_plugin, is_custom, is_keyword boolean columns down to a single column taking values in {plugin, custom, keyword, other}. The motivation is that it makes the table easier to visually digest (and arguably easier to query?).

Before

image

After

image

@dandavison dandavison marked this pull request as draft November 8, 2022 02:29
@dandavison dandavison force-pushed the help-commands-command-type branch from 86ed54a to aa944c0 Compare November 8, 2022 02:41
(false, true, false, false) => CommandType::Custom,
(_, false, true, false) => CommandType::Keyword,
(false, false, false, true) => CommandType::Plugin,
_ => CommandType::Other,
Copy link
Contributor Author

@dandavison dandavison Nov 8, 2022

Choose a reason for hiding this comment

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

I discovered via trial and error that Keyword is also a Builtin. If people like this direction, maybe someone who knows the language internals better could take a look at this match statement: is it making any incorrect assumptions about mutual exclusivity and are there things being classified as Other that should not be?

@dandavison dandavison marked this pull request as ready for review November 8, 2022 03:15
@rgwood rgwood added the notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes label Nov 10, 2022
@rgwood
Copy link
Contributor

rgwood commented Nov 10, 2022

Thanks! We agreed in the Discord meeting today that this looks like a solid improvement.

Whenever you have time, could you please document this in the breaking changes section for the 0.72 release? nushell/nushell.github.io#666

@rgwood rgwood merged commit fe14e52 into nushell:main Nov 10, 2022
@dandavison
Copy link
Contributor Author

@rgwood I realised there was a bug here: follow up PR #7074

@rgwood
Copy link
Contributor

rgwood commented Nov 10, 2022

Documented this breaking change in the v0.72 blog post.

@fdncred
Copy link
Contributor

fdncred commented Nov 10, 2022

Plugins are no longer able to be found in help commands since is_plugin was removed. Hopefully we can fix this.

@dandavison
Copy link
Contributor Author

@fdncred would you be able to print out the value of the 4 booleans in the command_type match statement for a plugin?

@fdncred
Copy link
Contributor

fdncred commented Nov 10, 2022

I can, in a little while. This is what it looks like now. The "other" ones are plugins
image

@dandavison
Copy link
Contributor Author

Hm, yeah we need to figure out the right place to put wildcards (_), and the right order, for the match cases here:

self.is_builtin(),
self.is_custom_command(),
self.is_parser_keyword(),
self.is_known_external(),
self.is_plugin().is_some(),
) {
(true, false, false, false, false) => CommandType::Builtin,
(true, true, false, false, false) => CommandType::Custom,
(true, false, true, false, false) => CommandType::Keyword,
(false, true, false, true, false) => CommandType::External,
(false, false, false, false, true) => CommandType::Plugin,
_ => CommandType::Other,
}
}

@fdncred
Copy link
Contributor

fdncred commented Nov 10, 2022

I added this

    fn command_type(&self) -> CommandType {
        match (
            self.is_builtin(),
            self.is_custom_command(),
            self.is_parser_keyword(),
            self.is_known_external(),
            self.is_plugin().is_some(),
        ) {
            (true, false, false, false, false) => CommandType::Builtin,
            (true, true, false, false, false) => CommandType::Custom,
            (true, false, true, false, false) => CommandType::Keyword,
            (false, true, false, true, false) => CommandType::External,
            (false, false, false, false, true) => CommandType::Plugin,
            _ => {
                eprintln!(
                    "
                builtin: {}, custom: {}, keyword: {}, known_external: {}, plugin: {}",
                    self.is_builtin(),
                    self.is_custom_command(),
                    self.is_parser_keyword(),
                    self.is_known_external(),
                    self.is_plugin().is_some()
                );
                CommandType::Other
            }
        }
    }

image

@fdncred
Copy link
Contributor

fdncred commented Nov 10, 2022

fixed here #7088
i just made plugins true, false, false, false, true

TornaxO7 added a commit to TornaxO7/nushell.github.io that referenced this pull request Jan 1, 2023
If I'm understanding that correctly from [this PR](nushell/nushell#7052) `command_type` should be `plugin` if it comes from a plugin.
rgwood pushed a commit to nushell/nushell.github.io that referenced this pull request Jan 2, 2023
If I'm understanding that correctly from [this PR](nushell/nushell#7052) `command_type` should be `plugin` if it comes from a plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants