Skip to content

REFACTOR: remove the shell commands#8415

Merged
fdncred merged 12 commits intonushell:mainfrom
amtoine:refactor/remove-the-shell-commands
May 13, 2023
Merged

REFACTOR: remove the shell commands#8415
fdncred merged 12 commits intonushell:mainfrom
amtoine:refactor/remove-the-shell-commands

Conversation

@amtoine
Copy link
Copy Markdown
Member

@amtoine amtoine commented Mar 12, 2023

Related to #8368.

Description

as planned in #8311, the enter, shells, g, n and p commands have been re-implemented in pure-nushell in the standard library.
this PR removes the rust implementations of these commands.

  • all the "shells" tests have been removed from crates/nu-commnand/tests/commands/ in 2cc6a82, except for the exit command
  • cd does not use the shells feature in its source code anymore => that does not change its single-shell behaviour
  • all the command implementations have been removed from crates/nu-command/src/shells/, except for exit.rs => mod.rs has been modified accordingly
  • the exit command now does not compute any "shell" related things
  • the --now option has been removed from exit, as it does not serve any purpose without sub-shells

User-Facing Changes

users may now not use enter, shells, g, n and p
now they would have to use the standard library to have access to equivalent features, thanks to the dirs.nu module introduced by @bobhy in #8368

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • toolkit test
  • toolkit test stdlib

After Submitting

the website will have to be regenerated to reflect the removed commands 👍

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2023

Codecov Report

Merging #8415 (662056e) into main (8d8304c) will decrease coverage by 0.07%.
The diff coverage is 92.85%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8415      +/-   ##
==========================================
- Coverage   68.99%   68.93%   -0.07%     
==========================================
  Files         641      635       -6     
  Lines      102470   102041     -429     
==========================================
- Hits        70703    70341     -362     
+ Misses      31767    31700      -67     
Impacted Files Coverage Δ
crates/nu-command/src/default_context.rs 99.77% <ø> (-0.01%) ⬇️
crates/nu-command/src/filesystem/cd.rs 62.84% <ø> (-3.16%) ⬇️
crates/nu-command/src/shells/exit.rs 90.24% <83.33%> (-7.61%) ⬇️
crates/nu-std/src/lib.rs 81.98% <100.00%> (+1.39%) ⬆️

... and 8 files with indirect coverage changes

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Mar 12, 2023

@kubouch
as in #8406, maybe this PR should be marked with the std-library tag as well? 😋

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Mar 12, 2023

It may be good to look at the tests here and make sure we have similar tests on the stdlib side.

@kubouch kubouch added the A:std-library Defining and improving the standard library written in Nu label Mar 12, 2023
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Mar 12, 2023

It may be good to look at the tests here and make sure we have similar tests on the stdlib side.

💯

i can file an issue to list these tests once this PR is merged?

@bobhy
Copy link
Copy Markdown
Contributor

bobhy commented Mar 12, 2023 via email

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Mar 13, 2023

Can we hold off on merging this until we have an easy way for user to install the standard library? I'm working on a manual install that should be ready real soon now, then we could document a fairly smooth transition for users.

do not worry, this will stay a DRAFT until that time has come 😉

and it's mentionned at the very top in the ":warning: Warning" 😋

This should solve the merge conflicts from nushell#8415.
@amtoine amtoine self-assigned this Apr 28, 2023
@amtoine amtoine marked this pull request as ready for review April 28, 2023 08:38
@fdncred fdncred added the notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes label Apr 28, 2023
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 28, 2023

I have a tiny bit of hesitancy because we're essentially replacing the shells commands with nearly identical clones but we're changing all the names. I'm wondering if we should either name the dirs commands to match or make aliases to help shells users get up to speed without spending time figuring out what is broken? Interested in other's thoughts.

@bobhy
Copy link
Copy Markdown
Contributor

bobhy commented Apr 29, 2023 via email

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Apr 29, 2023

i do not have a strong preference 🤔 😋

  • i feel the "shell" commands are primarily used in an interactive REPL, so people that use them would only have to change muscle memory / use custom aliases, unlikely fix scripts
  • we can also fallback to the "legacy" names / ship "standard" aliases for backwards compatibility

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 12, 2023

what do we do here in the end @fdncred?
i do not use these commands, so i'm fine with either way 😇

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 12, 2023

i'd vote to land it after the next release in a coupld days if we can get synonym aliases for defs for backwards compatibility for enter, p, n, g. this probably also needs a git merge main since it's a bit old now.

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 12, 2023

i'd vote to land it after the next release in a coupld days

let's go for this then 😋

if we can get synonym aliases for defs for backwards compatibility for enter, p, n, g.

do you mean adding Nushell aliases in default_config.nu? 🤔

this probably also needs a git merge main since it's a bit old now.

there is no conflict, you just want to re run the CI with the latest main for integration?

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 12, 2023

do you mean adding Nushell aliases in default_config.nu? 🤔

I meant in the module itself so that anyone who uses it will have the backwards compatible usage.

there is no conflict, you just want to re run the CI with the latest main for integration?

Even though the CI is green, there have been changes since the PR as submitted and sometimes we get into trouble if we have PRs that have set for a long time and then land them.

@kubouch
Copy link
Copy Markdown
Contributor

kubouch commented May 12, 2023

I think the dirs module could export the n, p etc. as aliases to the dirs commands and these could be added to the prelude to be loaded automatically. This way we don't rely on users periodically checking and updating their config after every release.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 12, 2023

I think the dirs module could export the n, p etc. as aliases to the dirs commands and these could be added to the prelude to be loaded automatically. This way we don't rely on users periodically checking and updating their config after every release.

This is what I meant, just said better. 😄

This is to bring the latest `main` into nushell#8415 and check that the CI
runs without any issue. nushell#8415 has been open for quite a long time so
it does not cost anything to try the CI with a more recent `main`.
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 13, 2023

first, let's run the CI... ♻️

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 13, 2023

this should be better with the last two commits 😌

@amtoine amtoine requested review from fdncred and kubouch May 13, 2023 07:57
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 13, 2023

@amtoine I think this is close.

g isn't dirs show. g goes to a particular index. It looks like maybe we need a dirs goto something like:

alias g = dirs goto
def 'dirs goto' [idx: int] {
  # bounds checking is done in _fetch
  _fetch $idx
}

or maybe just

alias g = _fetch

I'm not sure either of these work but I think you get my point.

We have a dirs drop which works like exit with the shells commands but I don't think we should alias exit to something else. So, this is kind of a missing link. maybe alias dexit = dirs drop?

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 13, 2023

very good points @fdncred

  • i think g should be closer to the old built-in one now with 662056e
  • and new dexit alias in f21a64b

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 13, 2023

ok, let's try this removal and see if anyone notices.

@fdncred fdncred merged commit bf86cd5 into nushell:main May 13, 2023
@amtoine amtoine deleted the refactor/remove-the-shell-commands branch May 14, 2023 07:03
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 15, 2023

because we added the compatibility aliases, i'm wondering if this still is a breaking change 🤔

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 15, 2023

because we added the compatibility aliases, i'm wondering if this still is a breaking change 🤔

i think so, if only because exit is not dexit for the new shells commands. or maybe mostly-non-breaking, and only 1 command is a breaking change. not sure of a good way to state that.

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented May 15, 2023

if there is a single tiny detail which is a breaking change, then the whole thing is a breaking change 😌

bgeron added a commit to bgeron/nushell that referenced this pull request Jun 15, 2023
Since nushell#8415 it no longer manipulates shells.
bgeron added a commit to bgeron/nushell that referenced this pull request Jun 15, 2023
Since nushell#8415 it no longer manipulates shells.
amtoine pushed a commit that referenced this pull request Jun 16, 2023
Since #8415 the `exit` command no longer manipulates shells.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:std-library Defining and improving the standard library written in Nu notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes status:wait-until-after-nushell-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants