예제 #1
0
파일: main.py 프로젝트: methane/github-cli
def main():
    opts, args = main_parser.parse_args()

    if opts.help and not args:
        args = ['help']

    if not args:
        main_parser.error('You must provide a command. '
                          '(Use `gh help` to see a list of commands)')

    repository = ()
    if opts.repository and '/' in opts.repository:
        repository = opts.repository.split('/', 1)

    if opts.loc_aware and not repository:
        repository = get_repository_tuple()

    command = args[0].lower()
    load_command(command)
    status = 1

    if command in commands:
        commands[command].repository = repository
        status = commands[command].run(opts, args[1:])
        if status == commands[command].COMMAND_UNKNOWN:
            print('Unknown subcommand or option.')
            commands[command].help()

    sys.exit(status)
예제 #2
0
def main():
    opts, args = main_parser.parse_args()

    if opts.help and not args:
        args = ['help']

    if not args:
        main_parser.error('You must give a command. '
                          '(Use `gh help` to see a list of commands)')

    repository = ()
    if opts.repository and '/' in opts.repository:
        repository = opts.repository.split('/', 1)

    if opts.loc_aware and not repository:
        repository = get_repository_tuple()

    command = args[0].lower()
    load_command(command)
    status = 1

    if command in commands:
        commands[command].repository = repository
        status = commands[command].run(opts, args[1:])
        if status == commands[command].COMMAND_UNKNOWN:
            print('Unknown subcommand or option.')
            commands[command].help()
    else:
        main_parser.error('No such command "{0}"'.format(command))

    sys.exit(status)
예제 #3
0
 def test_get_repository_tuple(self):
     ret = get_repository_tuple()
     assert ('sigmavirus24', 'Todo.txt-python') == ret