Skip to content

add -f, --force for save command - #7262

Merged
fdncred merged 2 commits into
nushell:mainfrom
WindSoilder:force_flag_for_save
Dec 1, 2022
Merged

fdncred merged 2 commits into
nushell:mainfrom
WindSoilder:force_flag_for_save

Conversation

@WindSoilder

Copy link
Copy Markdown
Contributor

Description

Closes: #6920

User-Facing Changes

❯ "asdf" | save dump.rdb
Error:
  × Destination file already exists
   ╭─[entry #21:1:1]
 1 │ "asdf" | save dump.rdb
   ·               ────┬───
   ·                   ╰── Destination file '/tmp/dump.rdb' already exists
   ╰────
  help: you can use -f, --force to force overwriting the destination

Tests + Formatting

Don't forget to add tests that cover your changes.

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

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

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

@sholderbach sholderbach added notes:breaking-changes Noted in Breaking Changes section A:file-system Related to commands and core nushell behavior around the file system status:wait-until-after-nushell-release labels Nov 28, 2022
@rgwood

rgwood commented Nov 28, 2022

Copy link
Copy Markdown
Contributor

LGTM, thanks!

@fdncred
fdncred merged commit bc3dc98 into nushell:main Dec 1, 2022
@remmycat

remmycat commented Dec 1, 2022 •

Copy link
Copy Markdown

This change might come with a bit of churn for existing configuration files.

I believe it has been a common workaround for tools with nu integration to generate and save a setup script inside env.nu and then source that file inside config.nu. This usually overwrites a file at the same path every time, which will lead to an error now (unless the script is running for the first time)

I'm not entirely sure if this already justifies a two-step release with only a warning being shown at first. But I believe it should definitely be highlighted in the release notes.

I ran into this while trying to run the latest version from the main branch with this zoxide setup for nu inside my configs: https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide

Add this to your env file (find it by running $nu.env-path in Nushell):

zoxide init nushell | save ~/.zoxide.nu

Now, add this to the end of your config file (find it by running
$nu.config-path in Nushell):

source ~/.zoxide.nu

Note
zoxide only supports Nushell v0.63.0 and above.

It's similar for starship: https://starship.rs/#nushell

@fdncred

fdncred commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

@remmycat I ran into that identical problem this morning. Adding save -f fixed it of course, but I'm sure other people will run into this as well.

@WindSoilder
WindSoilder deleted the force_flag_for_save branch December 2, 2022 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:file-system Related to commands and core nushell behavior around the file system notes:breaking-changes Noted in Breaking Changes section status:wait-until-after-nushell-release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-f flag for save that, if absent, stops overwriting files when it also doesn't have -a

5 participants