Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert short options to long ones, 2023 edition #8276

Merged
merged 2 commits into from
May 17, 2023

Conversation

aschmolck
Copy link
Contributor

Motivation

e.g. nix-env -e subversion => nix-env --uninstall subversion

The aim is to make the documentation less cryptic for newcomers and the long
options are more self-documenting.

The change was made with the following script:

https://github.com/aschmolck/convert-short-nix-opts-to-long-ones

and sanity checked visually.

Context

This is a 2023 update to #1280.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@roberth
Copy link
Member

roberth commented May 10, 2023

Even as a big fan of long options, I have to agree with Eelco's comment on an earlier iteration that some short flags should actually be used, because they're used so frequently that they're worth learning even for a beginner.
After all the learning curve has two dimensions and we have to make a tradeoff between adding a small bump early or heaving to learn something twice (or like 1.5×, whatever).
For me the bumps that are worth taking early are

  • -A for attribute
  • nix-store -q for query, question, whatever, doesn't even matter. I feel like associating this is easy because few prominent words start with q. Only query/question and queue come to mind.
  • Maybe -f for file if we're going to teach with the new cli before flakes

All of the other flags, I think we should teach with long names.

I suppose there could be disagreement about which short flags. If there is, let's err on the long side. Otherwise pick 3 or 4, but I'd say no more than that.

@aschmolck
Copy link
Contributor Author

@roberth I agree that for a few common and intuitive option make sense to abbreviate them. With the "new" nix command (which didn't exist when I sent the original PR years ago), the problem has been greatly reduced in any case.

I'm happy to keep the short form -A for --attr and -q for --query (even if these only occur in nix-env and friends, not the new nix command, I think) and -f for --file as you suggest. If no one objects, I will make this change. Is anything else required to merge this?

@fricklerhandwerk
Copy link
Contributor

I actually object. In particular, since nix-env is still the only stable command for profiles and tutorials and third party documentation all over the place suggesting its use, query and attr do help understanding what these things do. I'm for expanding all flags. The manual should be super explicit.

@aschmolck
Copy link
Contributor Author

In that case, I would suggest we go with @roberth's suggestion that if there is [disagreement] let's err on the long side and merge as is. I feel pretty confident that this change represents an overall improvement, even if there remain slight differences in preferences.

@roberth
Copy link
Member

roberth commented May 16, 2023

I can't tell if the changes to release notes are accurate, especially old ones. It'd be possible to accidentally change them to long options that didn't exist in those releases. So for historical accuracy it'd be better to leave those untouched. (Or did you/someone actually research this?)

Other than that, I don't care too deeply about keeping the frequently used ones.

@Ericson2314
Copy link
Member

That sounds good to me; let's keep the old release notes as is, and do the rest.

Thanks @aschmolck for bearing with us so long after the first PR!

e.g. nix-env -e subversion => nix-env --uninstall subversion

The aim is to make the documentation less cryptic for newcomers and the
long options are more self-documenting.

The change was made with the following script:

<https://github.com/aschmolck/convert-short-nix-opts-to-long-ones>

and sanity checked visually.
@aschmolck
Copy link
Contributor Author

Done!

@roberth roberth enabled auto-merge May 17, 2023 10:21
@roberth roberth merged commit f1cbc4c into NixOS:master May 17, 2023
8 checks passed
thenbe added a commit to thenbe/nix that referenced this pull request Sep 7, 2023
The `-c` flag belongs to `sh` not `nix shell`. As it stands, the command errors with:

```
$ nix shell nixpkgs#gnumake --command sh --command "cd src && make"
sh: --command: invalid option
```

NixOS#8276 was good for readability, but it missed this since that PR used a find/replace script.
fricklerhandwerk pushed a commit that referenced this pull request Sep 7, 2023
The `-c` flag belongs to `sh` not `nix shell`. As it stands, the command errors with:

```
$ nix shell nixpkgs#gnumake --command sh --command "cd src && make"
sh: --command: invalid option
```

#8276 was good for readability, but it missed this since that PR used a find/replace script.
fricklerhandwerk pushed a commit to fricklerhandwerk/nix that referenced this pull request Sep 25, 2023
The `-c` flag belongs to `sh` not `nix shell`. As it stands, the command errors with:

```
$ nix shell nixpkgs#gnumake --command sh --command "cd src && make"
sh: --command: invalid option
```

NixOS#8276 was good for readability, but it missed this since that PR used a find/replace script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation new-cli Relating to the "nix" command
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants