Hello everybody,
first, let me wish you a happy new year, health and good luck. I'm currently working on using argparse to improve the way command line arguments are parsed, in a way compatible with the old handling while developing a new, hopefully more logical and easier to extend, approach. The attached script is a proof-of-concept, faking the interface and printing the result (without any real action), for which I'd like to get feedback, especially regarding your daily use of rdiff-backup: 1. is the compatible interface really similar to the old command line? 2. is the output using the old and new interfaces the same? (ignoring "null" default values) 3. how do you like the new interface? any feedback is welcome. Few more notes to get you started: `python3 arguments.py --help` gives you the old interface `python3 arguments.py --new --help` gives you the new one the new interface makes more clearly the difference between actions (backup, restore, compare, etc...) and options, e.g. the old `rdiff-backup -b dir1 dir2` becomes `rdiff-backup backup dir1 dir2`. A neat trick of the new interface is the ability to create arguments files, e.g. restore.txt with one argument per line: restore --at 3B repository_dir target_dir and use it on the command line with `python3 arguments.py @restore.txt` I find that filtering away the null values helps to understand the output, e.g. with `| grep -v null`. Hope you like it, let me know in both cases :-) Thanks, Eric |
On 02/01/2021 20:38, Eric L. Zolf wrote: > Hello everybody, > > first, let me wish you a happy new year, health and good luck. > > I'm currently working on using argparse to improve the way command line > arguments are parsed, in a way compatible with the old handling while > developing a new, hopefully more logical and easier to extend, approach. > > The attached script is a proof-of-concept, faking the interface and > printing the result (without any real action), for which I'd like to get > feedback, especially regarding your daily use of rdiff-backup: > > 1. is the compatible interface really similar to the old command line? > 2. is the output using the old and new interfaces the same? (ignoring > "null" default values) > 3. how do you like the new interface? any feedback is welcome. > > Few more notes to get you started: > > `python3 arguments.py --help` gives you the old interface > `python3 arguments.py --new --help` gives you the new one > the new interface makes more clearly the difference between actions > (backup, restore, compare, etc...) and options, e.g. the old > `rdiff-backup -b dir1 dir2` becomes `rdiff-backup backup dir1 dir2`. > A neat trick of the new interface is the ability to create arguments > files, e.g. restore.txt with one argument per line: > > restore > --at > 3B > repository_dir > target_dir > > and use it on the command line with `python3 arguments.py @restore.txt` > > I find that filtering away the null values helps to understand the > output, e.g. with `| grep -v null`. > > Hope you like it, let me know in both cases :-) > > Thanks, Eric > Thanks Eric for all your great work on rdiff-backup over the last year (I now use v2.0.5 on Ubuntu 20.04 and Windows [latter only as client], it works great), and all the best for 2021. But when I try arguments.py I get this: # python3 --version Python 3.8.5 # python3 ./arguments.py --help Traceback (most recent call last): File "./arguments.py", line 120, in <module> "--fsync", default=True, action=argparse.BooleanOptionalAction, AttributeError: module 'argparse' has no attribute 'BooleanOptionalAction' |
Hi Dominic,
On 05/01/2021 12:39, Dominic Raferd wrote: > Thanks Eric for all your great work on rdiff-backup over the last year > (I now use v2.0.5 on Ubuntu 20.04 and Windows [latter only as client], > it works great), and all the best for 2021. Thanks a lot for the kind words. > But when I try arguments.py I get this: > # python3 --version > Python 3.8.5 > # python3 ./arguments.py --help > Traceback (most recent call last): > File "./arguments.py", line 120, in <module> > "--fsync", default=True, action=argparse.BooleanOptionalAction, > AttributeError: module 'argparse' has no attribute 'BooleanOptionalAction' I can only apologize, I forgot to test on lower versions of Python and did only work with Python 3.9 [1]. The attached version should now work with python down to version 3.6. Sorry for the inconvenience, Eric [1] to my defense, the argparse documentation doesn't say that BooleanOptionalAction is new with 3.9 |
Free forum by Nabble | Edit this page |