Пример #1
0
    def execute(self):
        params = {}

        if self.args.user:
            params['user'] = self.args.user[0]

        if self.args.repo:
            params['repo'] = self.args.repo[0]

        if self.args.labels:
            params['labels'] = self.args.labels[0]

        if self.args.filter[0] in self.allowed_filters:
            params['filter'] = self.args.filter[0]

        if self.args.state[0] in self.allowed_states:
            params['state'] = self.args.state[0]

        if self.args.sort[0] in self.allowed_sort:
            params['sort'] = self.args.sort[0]

        if self.args.direction[0] in self.allowed_directions:
            params['direction'] = self.args.direction[0]

        gh = Github("https://api.github.com")
        ret = gh.issues(params)

        for issue in ret:
            print('[ %(url)s ] %(title)s' % { 'url': issue['html_url'], 'title': issue['title']})
Пример #2
0
    def execute(self):
        # TODO Blindly assume that we don't mind nuking config
        gh = Github("https://api.github.com")
        oauth = OauthWrapper()
        with github_cli.config.Config().new() as conf:
            webbrowser.open(gh.oauth.auth_url(id=oauth.get_id()))

            code = oauth.get_code()
            req_data = {
                "client_id": github_cli.config.CLIENT_KEY,
                "client_secret": github_cli.config.CLIENT_SECRET,
                "code": code
                }

            conf["access_token"] = gh.oauth("access_token", req_data)["access_token"]
            conf["username"] = self.args.username