Esempio n. 1
0
 /**
  * Sets up the help message output for the help command
  *
  * @param Help $help The CLI help object used to configure help messages
  * @return Help
  */
 public static function configureHelp(Help $help)
 {
     $help->setUsage(self::$usage);
     $help->setDescr(self::$description);
     $help->setOptions([]);
     return $help;
 }
Esempio n. 2
0
 public function getHelp($name)
 {
     $help = parent::getHelp($name);
     // Make subjects green
     $subjectpattern = '/(?<! )<<bold>>(.*)<<reset>>/';
     $subjectPainter = function ($matches) {
         return '<<green>>' . ucfirst(strtolower($matches[1])) . '<<reset>>';
     };
     $help = preg_replace_callback($subjectpattern, $subjectPainter, $help);
     // Make options yellow
     $help = preg_replace("/ (-[a-z],?(?! )|--[a-z][a-z-]+)/", ' <<yellow>>\\1<<reset>>', $help);
     $help = preg_replace("/(?<!<)<([^<> ]+)>(?!>)/", '<<yellow>><\\1><<reset>>', $help);
     $help = preg_replace("/\\[([^\\[\\] ]+)\\]/", '<<yellow>>[\\1]<<reset>>', $help);
     return $help;
 }
 /**
  * Sets up CLI help messages to display when using the "help" command
  *
  * @param Help $help The CLI help object used to configure help messages
  * @return Help
  */
 public static function configureHelp(Help $help)
 {
     if (isset(self::$usage)) {
         $help->setUsage(self::$usage);
     }
     if (isset(self::$description)) {
         $help->setDescr(self::$description);
     }
     if (isset(self::$options)) {
         $options = array_merge($help->getOptions(), self::$options);
         $help->setOptions($options);
     }
     return $help;
 }
Esempio n. 4
0
    exit(1);
}
use Aura\Cli\CliFactory;
use Aura\Cli\Status;
use Aura\Cli\Help;
use Aura\Cli\Context\GetoptParser;
use Aura\Cli\Context\OptionFactory;
use Dotenv;
use DisqusAPI;
use DisqusInterfaceNotDefined;
// Aura CLI library dependencies
$auraCli = new CliFactory();
$context = $auraCli->newContext($_SERVER);
$stdio = $auraCli->newStdio();
// Assemble the script usage instructions
$help = new Help(new OptionFactory());
$help->setSummary('A lightweight command line client for the Disqus API');
$help->setUsage("<resource> <verb> [optionlist]");
$help->setDescr('For a full list of Disqus API resources, verbs, and options, visit https://disqus.com/api/docs');
$help->setOptions($options);
// Parse the command line
$optionsParser = new GetoptParser(new OptionFactory());
$optionsParser->setOptions($options);
$optionsParser->parseInput($context->argv->get());
try {
    // Load the configuration .env file
    Dotenv::load(getcwd());
    Dotenv::required(['DISQUS_API_KEY', 'DISQUS_API_SECRET', 'DISQUS_ACCESS_TOKEN']);
} catch (\RuntimeException $e) {
    $stdio->errln($e->getMessage());
    exit(Status::CONFIG);
Esempio n. 5
0
 /**
  * @return \Aura\Cli\Help
  */
 private function createHelp()
 {
     $help = new Help(new OptionFactory());
     $help->setSummary('Write me to read me.');
     $help->setUsage(['[options] [--] <file>']);
     $help->setOptions($this->getOptions());
     $help->setDescr('Convert a WRITEME template to its README counterpart. e.g. WRITEME.md will be written to README.md. Override this using option --target or front-matter key "target"');
     return $help;
 }