digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.64k stars 120 forks source link

Add support for completing options without = #447

Closed aude closed 2 years ago

aude commented 2 years ago

Currently, option arguments are only completed after =. For example:

$ btrbk --loglevel=<TAB>
debug  error  info   trace  warn
$ btrbk --loglevel <TAB>
archive   diff      extents   ls        prune     run
stats     clean     dryrun    list      origin    resume
snapshot  usage

This commit makes it so that both option styles are recognized:

$ btrbk --loglevel=<TAB>
debug  error  info   trace  warn
$ btrbk --loglevel <TAB>
debug  error  info   trace  warn

This was the intention all along, but it was implemented incorrectly.

digint commented 2 years ago

uhrg missed that one for v0.32.1, will test/merge for next release

digint commented 2 years ago

I did some tests today, works fine, with a small flaw (which might be a bit confusing for the users):

$ btrbk --loglevel=debug <TAB>
archive   diff      extents   ls        prune     run       stats
clean     dryrun    list      origin    resume    snapshot  usage

$ btrbk --loglevel debug <TAB>
*nothing*

Is it possible to fix that?

aude commented 2 years ago

Nice catch!

The reason was that _btrbk_init_cmds did not understand config options could have values. In your example $ btrbk --loglevel debug <TAB>, it thought debug was a command.

I have pushed a new commit which teaches _btrbk_init_cmds about config options with values. It's ready for a new test if you want to.

digint commented 2 years ago

finally found some time to test this, works fine, thanks!

merged in: b618c2dd901501a26495617d664b74383b1492b9