Skip to content

Instantly share code, notes, and snippets.

@ygerasimov
Created January 15, 2020 19:19
Show Gist options
  • Save ygerasimov/6a265facfc062528d11b2488e56d59d1 to your computer and use it in GitHub Desktop.
Save ygerasimov/6a265facfc062528d11b2488e56d59d1 to your computer and use it in GitHub Desktop.
Diffy CLI auth:login command
<?php
namespace DiffyCli\Commands;
use Diffy\Diffy;
use DiffyCli\Config;
class AuthCommand extends \Robo\Tasks
{
/**
* Logs in to Diffy
*
* @command auth:login
*
* @param string $apiKey Your API Key. Obtain your key at https://app.diffy.website/#/keys.
*
* @usage auth:login <api_key> Saves the API Key <api_key> to configuration for future use.
*/
public function logIn($apiKey)
{
Diffy::setApiKey($apiKey);
// If authentication fail we would get exception already.
// So now it is safe to save the key to configuration.
Config::saveApiKey($apiKey);
$this->io()->success("Key is validated and saved");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment