Add format argument to argparser and actually use it

This commit is contained in:
Sebastian Lohff 2019-03-27 00:42:56 +01:00
parent 2fa09f88f7
commit b6e80b7288
1 changed files with 3 additions and 1 deletions

View File

@ -273,6 +273,8 @@ def main():
parser.add_argument("-a", "--add-user", default=[], nargs="+", parser.add_argument("-a", "--add-user", default=[], nargs="+",
help="Add users, format is username:key?:sudo?:gecos?:password?, " help="Add users, format is username:key?:sudo?:gecos?:password?, "
"sudo is a bool, key is either an ssh key or a path to an ssh key") "sudo is a bool, key is either an ssh key or a path to an ssh key")
parser.add_argument("-f", "--format", default=None, choices=('tgz', 'iso'),
help="Specify output format, default is to infer from output file extension")
args = parser.parse_args() args = parser.parse_args()
@ -339,7 +341,7 @@ def main():
cfgdrv.add_user(user[0], keys, sudo=sudo, gecos=gecos, password=password) cfgdrv.add_user(user[0], keys, sudo=sudo, gecos=gecos, password=password)
if args.output: if args.output:
cfgdrv.write_iso(args.output) cfgdrv.write_drive(args.output, args.format)
finally: finally:
if cfgdrv: if cfgdrv:
cfgdrv.close() cfgdrv.close()