Convert CLI parsing from DIY to argparse
This commit is contained in:
32
main.py
32
main.py
@ -3,13 +3,41 @@
|
||||
|
||||
from BackupRotator import BackupRotator
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
#
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Mike's Backup Rotator. Helps automatically remove old backup files or folders."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--config", "-c",
|
||||
dest="config_files",
|
||||
default=[],
|
||||
action="append",
|
||||
type=str,
|
||||
help="Specify a configuration file. Can be called multiple times."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dry-run", "-d",
|
||||
dest="dry_run",
|
||||
default=False,
|
||||
action="store_true",
|
||||
help="Only perform an analysis; Don't delete anything."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
rotator = BackupRotator()
|
||||
rotator.run()
|
||||
|
||||
rotator.run(
|
||||
configs=args.config_files,
|
||||
dry_run=args.dry_run
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
Reference in New Issue
Block a user