コード例 #1
0
ファイル: ConfigCommand.php プロジェクト: svenax/trello-cli
    /**
     * Execute this command according to given switches and parameters.
     *
     * @param InputInterface  $input
     * @param OutputInterface $output
     * @return int
     * @throws \InvalidArgumentException
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $cmd = $input->getArgument('cmd');
        switch ($cmd) {
            case 'get':
                $output->writeln(Settings::get($input->getArgument('option')));
                break;
            case 'set':
                Settings::set($input->getArgument('option'), $input->getArgument('value'));
                break;
            case 'generate':
                $url = 'https://trello.com/1/authorize?key=' . Auth::APP_KEY;
                $url .= '&name=trello+cli&expiration=never&response_type=token&scope=read,write';
                $output->writeln(<<<EOT
Paste this url into a browser when you are logged in to Trello, and then call
<info>trello config set user_token</info> with the token shown on the result page.

<info>{$url}</info>
EOT
);
                break;
            default:
                throw new \InvalidArgumentException("Unknown subcommand '{$cmd}'");
                break;
        }
        return 0;
    }
コード例 #2
0
ファイル: Auth.php プロジェクト: svenax/trello-cli
 public static function getClient()
 {
     if (self::$client === null) {
         self::$client = new Client();
         self::$client->authenticate(self::APP_KEY, Settings::get('user_token'), Client::AUTH_URL_CLIENT_ID);
     }
     return self::$client;
 }