Skip to content

Add argparse options

Julian R requested to merge julianr/rollback:add_argparse_options into master

This PR does 3 things:

  • removes support for automatic privilege elevation [1]
  • adds support for specifying the config file from the command-line using the -c or --cfg option
  • adds support for automounting subvolid 5 when the --mount flag is passed

Additionally, a few code changes were made for maintainability purposes:

  • code was formatted using python-black autoformatter
  • toplevel code was refactored to avoid side-effects in case this file is imported

Test plan: Ran without root privileges -> fails Ran with root privileges -> works Ran without /btrfsroot mounted and no --mount flag -> fails Ran with /btrfsroot mounted and no --mount flag -> works Ran without /btrfsroot mounted and --mount flag -> works Ran with /btrfsroot mounted and --mount flag -> fails Ran with and without -c option to specify config file -> correct values are used

Please let me know if there's any change that you do not want to merge, or any behavior you'd like me to change, and I can fix things to your liking :-)

[1] Gaining root privileges should always be explicit, and even without looking specifically at that scenario, tools that attempt to be smart and do "magic" often wind up doing something the user doesn't expect and/or doesn't want.

Merge request reports