Browse code

Support multiple --only

Lorenz Hüdepohl authored on25/11/2017 04:53:26
Showing1 changed files
... ...
@@ -89,19 +89,19 @@ parser.add_argument('tagname', metavar='TAGNAME', type=str,
89 89
                      'property will be ignored and the command line value used\n'
90 90
                      'instead. VALUE can be 0, in which case all existing\n'
91 91
                      'snapshots will be deleted and no new snapshot will be\n'
92
-                     'created.')
92
+                     'created')
93 93
 
94 94
 parser.add_argument('-v', '--verbose', action="store_true",
95
-		help='Echo the commands that are issued.')
95
+		help='Echo the commands that are issued')
96 96
 
97 97
 parser.add_argument('-d', '--delete-only', action="store_true",
98
-                help='Do not make a new snapshot, but delete any old\nsurplus snapshots found.')
98
+                help='Do not make a new snapshot, but delete any old\nsurplus snapshots found')
99 99
 
100 100
 parser.add_argument('-n', '--dry-run', action="store_true",
101
-		help='Only echo the commands that would be issued,\ndo not actually do anything.')
101
+		help='Only echo the commands that would be issued,\ndo not actually do anything')
102 102
 
103
-parser.add_argument('-o', '--only', metavar='POOL', type=str,
104
-                help='Only consider filesystems below POOL.')
103
+parser.add_argument('-o', '--only', action='append', metavar='FS', type=str,
104
+                help='Only consider filesystems below FS. Can be given multiple times')
105 105
 
106 106
 args = parser.parse_args()
107 107
 
... ...
@@ -118,10 +118,9 @@ def mutative_cmd(cmdargs):
118 118
     if not args.dry_run:
119 119
         check_call(cmdargs)
120 120
 
121
-if args.only:
122
-    only = ["-r", args.only]
123
-else:
124
-    only = []
121
+only = []
122
+for o in args.only:
123
+    only.extend(["-r", o])
125 124
 
126 125
 zfs_props = Popen([zfs, "get", "-t", "filesystem", "autosnapshot:{0}".format(args.tagname), "-H"] + only,
127 126
         stdout=PIPE)