]> scripts.mit.edu Git - wizard.git/blob - wizard/command/blacklist.py
Refactor change directory code to be consistent and permissive.
[wizard.git] / wizard / command / blacklist.py
1 import os
2
3 from wizard import command, shell, util
4
5 def main(argv, baton):
6     options, args = parse_args(argv, baton)
7     reason = args[0]
8     # XXX: this should be abstracted away!
9     if os.path.exists(".git/WIZARD_REPO"):
10         util.chdir(shell.eval('git', 'config', 'remote.origin.url'))
11     # Directory information not transferred via command line, so this
12     # will not error due to the changed directory.
13     shell.drop_priviledges(".", options.log_file)
14     open('.scripts/blacklisted', 'w').write(reason + "\n")
15
16 def parse_args(argv, baton):
17     usage = """usage: %prog blacklist [ARGS] REASON
18
19 Touches .scripts/blacklisted so that we don't attempt
20 to upgrade the script in the future."""
21     parser = command.WizardOptionParser(usage)
22     options, args = parser.parse_all(argv)
23     if len(args) > 2:
24         parser.error("too many arguments")
25     if len(args) < 1:
26         parser.error("must specify reason")
27     return options, args
28