Skip to content

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

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

add -f, --force for save command#7262
fdncred merged 2 commits intonushell: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 This PR implies a change affecting users and has to be noted in the release notes 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
Copy link
Copy Markdown
Contributor

rgwood commented Nov 28, 2022

LGTM, thanks!

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

remmycat commented Dec 1, 2022

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
Copy link
Copy Markdown
Contributor

fdncred commented Dec 1, 2022

@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 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.

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

5 participants