Example #1
0
 public function requireLog()
 {
     $this->_log = $this->positionalArgValue(0);
     if ($this->_log === null) {
         $log = new UserPrompt("Which log do you wish to access?");
         $log->addValidator(Validator::VALIDATE_LENGTH, [1, 100]);
         $this->_log = $log->show();
     }
 }
 /**
  * @param string $package
  * @param string $homeDir
  *
  * @return string
  */
 public function getPotentialLinkLocation($package, $homeDir)
 {
     $linkToPotentialLocation = false;
     $potentialLocation = build_path($homeDir, $package);
     if (file_exists($potentialLocation)) {
         $linkToPotentialLocation = UserPrompt::confirm(sprintf("> Link to '%s'?", $potentialLocation), 'y');
     }
     return $linkToPotentialLocation ? $potentialLocation : "";
 }
Example #3
0
 /**
  * @param ComposerSymLog  $log
  * @param ComposerSym     $composerSym
  * @param ComposerSymCore $core
  * @param array           $required
  *
  * @throws \Garoevans\ComposerSym\Exception\ComposerSymException
  */
 public static function run(ComposerSymLog $log, ComposerSym $composerSym, ComposerSymCore $core, array $required)
 {
     foreach ($required as $package => $version) {
         if (self::shouldSkip($log, $composerSym, $package)) {
             continue;
         }
         $doSymlink = UserPrompt::confirm(sprintf("\n> Would you like to symlink %s?", $package), 'n');
         if ($doSymlink) {
             self::runSymLink($log, $composerSym, $core, $package);
         }
     }
 }
Example #4
0
 /**
  * @param ComposerSymLog $log
  */
 public static function run(ComposerSymLog $log)
 {
     foreach ($log->getLinkedPackages() as $linkedPackage) {
         $doUnlink = UserPrompt::confirm(sprintf("\n> Would you like to unlink %s?", $linkedPackage->package), 'n');
         if ($doUnlink) {
             rmdir($linkedPackage->location);
             rename($linkedPackage->tempLocation, $linkedPackage->location);
             // Sometimes rename leaves a copy of both directories, we double check
             // that it's actually gone here and if not remove it.
             if (file_exists($linkedPackage->tempLocation)) {
                 rmdir($linkedPackage->tempLocation);
             }
             printf("> %s unlinked\n", $linkedPackage->package);
             $log->removePackage($linkedPackage->package);
         }
     }
 }
Example #5
0
 /**
  * Perform a database reset
  * --reset=true
  *
  * @return $this
  */
 protected function _resetDatabase()
 {
     if (!$this->reset) {
         return $this;
     }
     echo Shell::colourText("***** Resetting Database!!! *****", true, Shell::COLOUR_FOREGROUND_BROWN, Shell::COLOUR_BACKGROUND_RED);
     echo PHP_EOL;
     $reset = UserPrompt::confirm('Are you sure? You will lose ALL data?');
     if (!$reset) {
         exit;
     }
     /** @var RecordMapper[] $mappers */
     $mappers = [new User(), new Platform(), new PlatformText(), new Category(), new CategoryText(), new Article(), new ArticleText(), new ArticleSectionBlock(), new ArticleSection(), new Video(), new VideoCaption(), new VideoText(), new Walkthrough(), new WalkthroughStep(), new WalkthroughText()];
     foreach ($mappers as $mapper) {
         $mapper->createTable(true);
         echo Shell::colourText(sprintf("Dropped & Created `%s`", $mapper->tableName()), true, Shell::COLOUR_FOREGROUND_LIGHT_GREY, Shell::COLOUR_BACKGROUND_RED);
         echo PHP_EOL;
     }
     echo 'Done, now run without flag...' . PHP_EOL;
     exit;
 }