コード例 #1
0
 def test_run(self):
     opts, args = main_parser.parse_args(['issue.ls', '-n', '5'])
     SUCCESS = self.command.SUCCESS
     with patch.object(IssueCommand, 'get_repo'):
         with patch.object(self.command.repo, 'issue') as issue:
             issue.return_value = self.issue
             assert self.command.run(opts, args[1:]) == SUCCESS
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
 def test_run(self):
     opts, args = main_parser.parse_args(['issue', '30', 'comments'])
     SUCCESS = self.command.SUCCESS
     FAILURE = self.command.FAILURE
     with patch.object(IssueCommand, 'get_repo'):
         with patch.object(self.command.repo, 'issue') as issue:
             issue.return_value = self.issue
             assert self.command.run(opts, args[1:]) == SUCCESS
             assert self.command.run(opts, ['foo']) == FAILURE
コード例 #5
0
ファイル: test_issues.py プロジェクト: methane/github-cli
 def test_run(self):
     opts, args = main_parser.parse_args(['issues', '30', 'comments'])
     SUCCESS = self.command.SUCCESS
     COMMAND_UNKNOWN = self.command.COMMAND_UNKNOWN
     with patch.object(IssuesCommand, 'get_repo'):
         with patch.object(self.command.repo, 'issue') as issue:
             issue.return_value = self.issue
             assert self.command.run(opts, args[1:]) == SUCCESS
             assert self.command.run(opts, ['foo']) == COMMAND_UNKNOWN
コード例 #6
0
 def test_main_parser(self):
     opts, args = main_parser.parse_args(['-h'])
     assert opts.help is True