Created
February 19, 2014 22:42
-
-
Save ScreamingDev/9103205 to your computer and use it in GitHub Desktop.
very first python :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import git | |
| import os | |
| import colorama | |
| import shutil | |
| class InitAction(argparse.Action): | |
| def __call__(self, parser, namespace, values, option_string=None): | |
| if os.path.isdir(".git"): | |
| print colorama.Fore.YELLOW + "This is already a project. Skipping the rest." | |
| return | |
| repo = git.Repo.init(os.curdir) | |
| print colorama.Fore.GREEN + "Created new repo" | |
| class DestroyAction(argparse.Action): | |
| def __call__(self, parser, namespace, values, option_string=None): | |
| try: | |
| shutil.rmtree('.git') | |
| print colorama.Fore.GREEN + "Deleted repository" | |
| except OSError as ex: | |
| print colorama.Fore.RED + "Something went wrong. Is it realy a git repo?" | |
| parser = argparse.ArgumentParser(description="Clone repos and spread them in your project") | |
| parser.add_argument('-q', '--quiet', help="Only shows errors.", action='store_true') | |
| parser.add_argument('-v', '--verbose', help="Tell me more about it!", action='store_true') | |
| parser.add_argument('--init', help="Set up the basic structure", action=InitAction, nargs=0) | |
| parser.add_argument('--destroy', help="Bye bye beautiful!", action=DestroyAction, nargs=0) | |
| parser.parse_args() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment