just icon indicating copy to clipboard operation
just copied to clipboard

Feature idea: Confirmation that defaults to Y

Open RobertMueller2 opened this issue 8 months ago • 1 comments

Consider the following justfile:

default: backup

backup: clean (_backup "Notes") (_backup "Quicknotes3") (_backup "Orga") (_backup "Cheatsheets") && git-commit

_backup directory:
    mkdir -p {{directory}}
    (cd ../{{directory}} && tar -cf - .) | (cd {{directory}} && tar -xvpf -)

clean:
    -rm -rf Notes Quicknotes3 Orga Cheatsheets

[confirm('Commit? (y/N)')]
git-commit commitmsg="adding backup at `date`": && git-push
    git add .
    git commit -m "{{commitmsg}}"

[confirm('Push? (y/N)')]
git-push:
    git push

99% of the time I'd answer both questions yes. But the source directories are cloud synced, sometimes they lose files or have additional files due to sync conflicts. In that case I'd interrupt, clean up and try again.

So it would be nice to have a confirmation that defaults to yes for both recipes, perhaps along the lines of confirm('Commit? (Y/n)', default='y'), so I can just enter enter enter through, but still allows me to say no, which means, --yes doesn't really work here.

This has some synergy with #2284 which could also be controlled by an additional parameter, as well as with #2248 which this could provide a use case for. Starting with three possible parameters, defaults/naming them vs positional need considering, I think that might not be covered 100% by #2248 but I could be mistaken after just a quick glance.

Of course, a shell read prompt here is an obvious and suitable workaround.

Would you accept a PR for this that builds on #2248?

RobertMueller2 avatar Apr 13 '25 07:04 RobertMueller2

hmm, or maybe #2248 isn't really needed, with the changes from 496f6b08d48e8e0dda2054bfce6ab07b755b47ca.

RobertMueller2 avatar Apr 15 '25 21:04 RobertMueller2

I would almost be inclined to add a different attribute, maybe [wait] or [pause] which is like [confirm], but only requires you to hit enter, and if you don't want to run it, you can CTRL-C. Not sure it's worth the extra attribute, but adding more arguments to [confirm] doesn't seem ideal.

casey avatar Jun 24 '25 07:06 casey

Obviously, the pause attribute isn't hard to implement. I was almost done a few months ago except for a question about how to best test Ctrl+c. But the more I think about it, the less I see any value added by this feature. So I'll just close the issue instead. Sorry for the noise. ;)

RobertMueller2 avatar Oct 04 '25 13:10 RobertMueller2