def begin():
    """
    Usage:
      octogit [subcommand] [arguments]
      octogit login | -l | --login [(username password)]
      octogit create <repo> [<description>] [<organization>]
      octogit (issues | -i | --issues) [--assigned | -a]
      octogit (issues | -i | --issues) create <issue-title> <description>
      octogit (issues | -i | --issues) <number> [close | view]
      octogit -v | --version
      octogit help | -h | --help

      """

    if os.path.exists(CONFIG_FILE):
        pass
    else:
        # create config file
        create_config()
        # commit changes
        commit_changes()

    arguments = docopt(begin.__doc__, help=None)

    if arguments['--version'] or arguments['-v']:
        puts(version())
        sys.exit(0)

    elif arguments['--help'] or arguments['-h'] or arguments['help']:
        get_help()
        sys.exit(0)

    elif arguments['create']:
        if arguments['<repo>'] == None:
            puts('{0}. {1}'.format(colored.blue('octogit'),
                colored.red('You need to pass both a project name and description')))

        else:
            project_name = arguments['<repo>']
            description = arguments['<description>'] or ''
            organization = arguments['<organization>'] or None
            create_repository(project_name, description, organization=organization)
            sys.exit()

    elif arguments['--issues'] or arguments['-i'] or arguments['issues']:
        url = find_github_remote()
        username, url = get_username_and_repo(url)
        if arguments['create']:
            if ['<issue-title>'] == None:
                puts('{0}. {1}'.format(colored.blue('octogit'),
                    colored.red('You need to pass an issue title')))
                sys.exit(-1)

            else:
                issue_name = arguments['<issue-title>']
                description = arguments['<description>']
                create_issue(username, url, issue_name, description)
                sys.exit(0)

        issue_number = arguments['<number>']

        if issue_number is not None:
            if issue_number.startswith('#'):
                issue_number = issue_number[1:]

            if arguments['close']:
                close_issue(username, url, issue_number)
                sys.exit(0)
            elif arguments['view']:
                view_issue(username, url, issue_number)
                sys.exit(0)
            elif arguments['--assigned']:
                get_issues(username, url, (arguments['-assigned'] or arguments['-a']))
                sys.exit(0)
            else:
                get_single_issue(username, url, issue_number)
                sys.exit(0)
        else:
                get_issues(username, url, False)
                sys.exit(0)

    elif arguments['--login'] or arguments['-l'] or arguments['login']:
        username = arguments['username'] or None
        if username is None:
            username = raw_input("Github username: ")
            if len(username) == 0:
                puts("{0}. {1}".format(
                        colored.blue("octogit"),
                        colored.red("Username was blank")))

        password = arguments['password'] or None
        if password is None:
            import getpass
            password = getpass.getpass("Password for %s: " % username)

        login(username, password)
    else:
        get_help()
        sys.exit(0)
dataset/ETHPy150Open myusuf3/octogit/octogit/cli.py/begin/original