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

FR: add config for default options #1509

Closed
fowles opened this issue Apr 12, 2023 · 3 comments
Closed

FR: add config for default options #1509

fowles opened this issue Apr 12, 2023 · 3 comments

Comments

@fowles
Copy link
Contributor

fowles commented Apr 12, 2023

I would like to be able to set default arguments that apply to commands if no other arguments are provided. I know that something similar can be accomplished with aliases, but I like being able to use commands like jj log with some customization.

I tried to implement it in

fowles@c4c8040

but I got lost trying to work with the clap module. If you would be receptive to this feature and can point me in the right direction, I can try to finish a PR, but if you don't like it I would rather learn that then continue spelunking through clap docs.

@martinvonz
Copy link
Member

Mercurial has this feature, and I remember they deprecated it, but I couldn't remember why. After some quick digging, I found https://lists.mercurial-scm.org/pipermail/mercurial-devel/2009-October/016095.html. For reference, the arguments there are:

  • It can be hard to override the defaults. If you make --reversed the default log order, we'd need to add a --no-reversed option for this case.
  • It's likely to confuse scripts.
  • It's likely to confuse your coworkers when they're trying to help you with something on your machine.

The last two points also apply to more specific config options, like diff.format (which can be set to "git", for example). Mercurial has its $HGPLAIN environment variable for the script case: scripts are supposed to set that variable, which disables most UI customizations.

So I'm not sure if we want to add this feature, but I'm also not sure that shouldn't.

@fowles
Copy link
Contributor Author

fowles commented Apr 12, 2023

If a real project had cause to deprecate it, then I will listen to that wisdom. It was probably painfully learned.

@fowles fowles closed this as completed Apr 12, 2023
@durin42
Copy link
Contributor

durin42 commented Apr 17, 2023

@martinvonz summarized the issues correctly. It might be less of an issue iff you could convince people to use a proper API to interact with jj working copies, but as a practical matter I've known too many programmers and they'll absolutely write skeevy shell scripts that will be broken by changes in default values. In general it's been significantly more sustainable to use a config section like alias to allow users to define their own custom commands which don't break out-of-the-box scriptability.

Git has tried to deal with this by having commands be "plumbing" and "porcelain" and then insisting that you only write scripts with the former. In practice...nobody listens until they get burned, and then the horse is already out of the barn and in the next county.

Hyrum's Law always finds you.

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

No branches or pull requests

3 participants