$this->cfg = $cfg;
}
+ public static function opts(\Console_CommandLine $optParser)
+ {
+ $cmd = $optParser->addCommand('connect');
+ $cmd->description = 'Obtain access token from a micropub server';
+ $cmd->addOption(
+ 'force',
+ array(
+ 'short_name' => '-f',
+ 'long_name' => '--force-update',
+ 'description' => 'Force token update if token already available',
+ 'action' => 'StoreTrue',
+ 'default' => false,
+ )
+ );
+ $cmd->addArgument(
+ 'server',
+ [
+ 'optional' => false,
+ 'description' => 'Server URL',
+ ]
+ );
+ $cmd->addArgument(
+ 'user',
+ [
+ 'optional' => true,
+ 'description' => 'User URL',
+ ]
+ );
+ $cmd->addArgument(
+ 'key',
+ [
+ 'optional' => true,
+ 'description' => 'Short name (key)',
+ ]
+ );
+ }
+
public function run($server, $user, $newKey, $force)
{
$server = Validator::url($server, 'server');
list($redirect_uri, $socketStr) = $this->getHttpServerData();
$state = time();
- echo "To authenticate, open the following URL:\n"
+ Log::msg(
+ "To authenticate, open the following URL:\n"
. $this->getBrowserAuthUrl($host, $user, $redirect_uri, $state)
- . "\n";
+ );
$authParams = $this->startHttpServer($socketStr);
if ($authParams['state'] != $state) {
}
$this->cfg->hosts[$hostKey] = $host;
$this->cfg->save();
- echo "Server configuration $hostKey saved successfully.\n";
+ Log::info("Server configuration $hostKey saved successfully.");
}
protected function fetchAccessToken(