From 40de76124826c6f24a11c0a7d752e37a7af977d9 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 14 Jun 2009 00:10:05 -0400 Subject: [PATCH] Add 'wizard migrate' stub, improve wizard bin. Signed-off-by: Edward Z. Yang --- bin/wizard | 12 ++++++------ lib/wizard/command/__init__.py | 2 +- lib/wizard/command/migrate.py | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 lib/wizard/command/migrate.py diff --git a/bin/wizard b/bin/wizard index 1b75035..4fac5dc 100755 --- a/bin/wizard +++ b/bin/wizard @@ -22,11 +22,10 @@ def main(): Wizard is a Git-based autoinstall management system for scripts. Its commands are: + migrate Migrate autoinstalls from old format to Git-based format stat Generate statistics about autoinstalls -See '%prog help COMMAND' for more information on a specific command. -""" -# migrate Migrate autoinstalls from old format to Git-based format +See '%prog help COMMAND' for more information on a specific command.""" parser = optparse.OptionParser(usage) parser.add_option("-d", "--version-dir", dest="version_dir", @@ -37,11 +36,12 @@ See '%prog help COMMAND' for more information on a specific command. try: while not sys.argv[i] or sys.argv[i][0] == '-': if sys.argv[i] == "-h" or sys.argv[i] == "--help": - parser.print_usage() + parser.print_help() raise SystemExit(-1) i += 1 except IndexError: - parser.error("no action specified") + parser.print_help() + raise SystemExit(-1) options, args = parser.parse_args(sys.argv[1:i+1]) rest_argv = sys.argv[i+1:] command = args[0] # shouldn't fail @@ -51,7 +51,7 @@ See '%prog help COMMAND' for more information on a specific command. except AttributeError: parser.error("invalid action") except IndexError: - parser.print_usage() + parser.print_help() raise SystemExit(-1) # Dispatch commands try: diff --git a/lib/wizard/command/__init__.py b/lib/wizard/command/__init__.py index 82bae4c..6ebe360 100644 --- a/lib/wizard/command/__init__.py +++ b/lib/wizard/command/__init__.py @@ -1 +1 @@ -import stat +import migrate, stat diff --git a/lib/wizard/command/migrate.py b/lib/wizard/command/migrate.py new file mode 100644 index 0000000..f626322 --- /dev/null +++ b/lib/wizard/command/migrate.py @@ -0,0 +1,26 @@ +import optparse +import sys + +import wizard.deploy as wd + +def main(argv, global_options): + usage = """usage: %prog migrate [ARGS] DIR + +Migrates a directory to our Git-based autoinstall format. +Performs basic sanity checking and intelligently determines +what repository and tag to use. + +NOTICE: Currently doesn't do anything.""" + parser = optparse.OptionParser(usage) + parser.add_option("-v", "--verbose", dest="verbose", action="store_true", + default=False, help="Print all commands and outputs") + parser.add_option("--dry-run", dest="dry_run", action="store_true", + default=False, help="Prints would would be run without changing anything") + options, args = parser.parse_args(argv) + if len(args) > 1: + parser.error("too many arguments") + elif not args: + parser.error("must specify directory") + dir = args[0] + print dir + print options -- 2.45.2