Skip to content

Rename all?, any? and empty? - #6464

Merged
sholderbach merged 4 commits into
nushell:mainfrom
adamijak:feat/rename
Sep 5, 2022
Merged

sholderbach merged 4 commits into
nushell:mainfrom
adamijak:feat/rename

Conversation

@adamijak

@adamijak adamijak commented Sep 2, 2022 •

Copy link
Copy Markdown

Description

Rename all?, any? and empty? to all, any and is-empty for sake of simplicity and consistency.

  • More understandable for newcomers, that these commands are no special to others.
  • ? syntax did not really aprove readability. For me it made it worse.
  • We can reserve ? syntax for any other nushell feature.

Work to be done

If this we confirm this PR, we also should

Tests

Make sure you've done the following:

  • Add tests that cover your changes, either in the command examples, the crate/tests folder, or in the /tests folder.
  • Try to think about corner cases and various ways how your changes could break. Cover them with tests.
  • If adding tests is not possible, please document in the PR body a minimal example with steps on how to reproduce so one can verify your change works.

Make sure you've run and fixed any issues with these commands:

  • [ x] cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • [ x] cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • [ x] cargo test --workspace --features=extra to check that all the tests pass

@adamijak adamijak changed the title Rename all?, any?, empty? Rename all?, any? and empty? Sep 2, 2022
@adamijak adamijak changed the title Rename all?, any? and empty? DRAFT: Rename all?, any? and empty? Sep 2, 2022
@adamijak adamijak changed the title DRAFT: Rename all?, any? and empty? Rename all?, any? and empty? Sep 2, 2022
@kubouch

kubouch commented Sep 2, 2022

Copy link
Copy Markdown
Contributor

I'd the name the empty command is-empty because empty by itself could mean both "is it empty?" (boolean query) and "to empty something" (command to delete something).

The all and any commands share the same problem to some extent (not clear whether it's a question or a an order). For example, all by itself could be interpreted as something like map (apply something to all elements). So, to me, the ? gives these commands a bit more clarity. But making them is-all and is-any is ugly, I'd rather have just all and any.

One thing to add here is to move the old commands to deprecated: https://github.com/nushell/nushell/blob/34e58bc5d65b5f10e0e1cd0ec66f0b031ea41975/crates/nu-command/src/deprecated/deprecated_commands.rs

@adamijak

adamijak commented Sep 2, 2022 •

Copy link
Copy Markdown
Author

We could take it step further and remove empty at all and use just any and all.
any can easily replace empty as this already works now

> [ ] | any? true
false
> [ 1 ] | any? true
true

we could make it

> [ ] | any
false
> [ 1 ] | any
true

@sholderbach

Copy link
Copy Markdown
Member

I am for removing the ? (My Rust brain associates it way too much with error handling or null-coaelescing operators)

One benefit of having a separate empty or is-empty command would be around how to deal with truthiness/implicit conversions to bools.

For example the empty string could have different effects: [] vs. [""]. If we say "" is empty. Would it evaluate as not any? So what would be the appropriate implict conversion behaviro here.

@kubouch

kubouch commented Sep 2, 2022

Copy link
Copy Markdown
Contributor

Yeah, there are edge cases with any. Maybe the empty removal would be a good topic for further discussion and a separate PR.

If most people want the ? removed, I'm fine with it, but I'd still go for is-empty.

@adamijak

adamijak commented Sep 2, 2022 •

Copy link
Copy Markdown
Author

@sholderbach like this?

> [ $nothing "" ] | is-empty
true
> [ $nothing "" ] | any
false

@sholderbach

Copy link
Copy Markdown
Member

I would consider the first list non-empty but evaluating false when using any

> [ $nothing "" ] | is-empty
true
> [ $nothing "" ] | any
false

@sholderbach

Copy link
Copy Markdown
Member

To add to your list of things that will have to happen with this PR on the documentation side and handling of breaking changes would be a short section for the release notes after it landed.

PR for the current release notes:
nushell/nushell.github.io#574

@stormasm

stormasm commented Sep 3, 2022

Copy link
Copy Markdown
Contributor

LGTM 👍

@fdncred

fdncred commented Sep 3, 2022

Copy link
Copy Markdown
Contributor

@adamijak Would you be willing to update the documentation for these changes? Not really the command help in the documentation, since that is systematically generated via a script, but any other references to these commands?

sholderbach added a commit to sholderbach/nu_scripts that referenced this pull request Sep 5, 2022
sholderbach added a commit to sholderbach/nu_scripts that referenced this pull request Sep 5, 2022
sholderbach added a commit to sholderbach/nu_scripts that referenced this pull request Sep 5, 2022
sholderbach added a commit to sholderbach/nushell.github.io that referenced this pull request Sep 5, 2022
Account for nushell/nushell#6464

`any?`/`all?`/`empty?` to `any`/`all`/`is-empty`
sholderbach added a commit to sholderbach/nushell.github.io that referenced this pull request Sep 5, 2022
Account for nushell/nushell#6464

`any?`/`all?`/`empty?` to `any`/`all`/`is-empty`
sholderbach added a commit to sholderbach/nushell.github.io that referenced this pull request Sep 5, 2022
@sholderbach

Copy link
Copy Markdown
Member

I have updated the docs and scripts under our organization accordingly, should be good to land

@sholderbach
sholderbach merged commit 1451298 into nushell:main Sep 5, 2022
sholderbach added a commit to nushell/nushell.github.io that referenced this pull request Sep 5, 2022
Account for nushell/nushell#6464

`any?`/`all?`/`empty?` to `any`/`all`/`is-empty`
sholderbach added a commit to nushell/nu_scripts that referenced this pull request Sep 5, 2022
…l`/`is-empty` (#287)

* Replace `all?` with `all` for nushell/nushell#6464

* Replace `any?` with `any` for nushell/nushell#6464

* Replace `emtpy?` with `is-empty`

Account for nushell/nushell#6464

* Ignore for `before_v0.60` scripts
sophiajt added a commit to nushell/nushell.github.io that referenced this pull request Sep 6, 2022
* add 68 blog

* add string distance and named durations

* Upgrade all vuepress plugins and fix doc search navigation by pressing `enter` key (#587)

* Upgrade  all vuepress plugins and fix doc search navigation by pressing `enter` key (#586)

* chore: upgrade vuepress plugins fix doc search navigation by enter key

* Update ci workflow

* chore: update ci

* chore: update ci

* Upgrade vuepress and all related plugins to improve build performance (#588)

* Breaking change note: dequestionmarked commands

Depends on landing nushell/nushell#6464

* Update types_of_data.md with missing values (#589)

'Duration' and 'File sizes' sections were incomplete with values missing.

For the duration `1month` I wrote "30 days" for clarification. A month can be anywhere from 28–31 days depending on the month while the program always seems to treat a month as 30 days.

* Update former question mark commands in docs (#590)

Account for nushell/nushell#6464

`any?`/`all?`/`empty?` to `any`/`all`/`is-empty`

* Document path split breaking change

* Add Homebrew PATH documentation

* Add module and overlay changes

* Reword source change; Add config table entries

* Rewrite dequestionmarking

* Oops

* More rewording

* Reformulate next steps

* Add links

* Add external completer section

* Update 2022-09-06-nushell-0_68.md

Co-authored-by: Justin Ma <[email protected]>
Co-authored-by: sholderbach <[email protected]>
Co-authored-by: Christer Jensen <[email protected]>
Co-authored-by: Reilly Wood <[email protected]>
Co-authored-by: kubouch <[email protected]>
Co-authored-by: JT <[email protected]>
hustcer pushed a commit to nushell/nushell.github.io that referenced this pull request Sep 7, 2022
maxim-uvarov pushed a commit to maxim-uvarov/nu_scripts_reduced_size that referenced this pull request Oct 12, 2024
…l`/`is-empty` (#287)

* Replace `all?` with `all` for nushell/nushell#6464

* Replace `any?` with `any` for nushell/nushell#6464

* Replace `emtpy?` with `is-empty`

Account for nushell/nushell#6464

* Ignore for `before_v0.60` scripts
maxim-uvarov pushed a commit to maxim-uvarov/nu_scripts_reduced_size that referenced this pull request Oct 13, 2024
…l`/`is-empty` (#287)

* Replace `all?` with `all` for nushell/nushell#6464

* Replace `any?` with `any` for nushell/nushell#6464

* Replace `emtpy?` with `is-empty`

Account for nushell/nushell#6464

* Ignore for `before_v0.60` scripts
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.

5 participants