Exemple #1
0
 /**
  * getOptionListYaml returns a YAML dump of default options.
  *
  * @param \nochso\WriteMe\Placeholder\OptionList $optionList
  *
  * @return string
  */
 public function getOptionListYaml(OptionList $optionList)
 {
     $data = [];
     foreach ($optionList->getOptions() as $option) {
         Dot::set($data, $option->getPath(), $option->getDefault());
     }
     return Yaml::dump($data);
 }
 /**
  * showPlaceholderOptions defaults and current values.
  *
  * @param \nochso\WriteMe\Placeholder\OptionList $defaults
  *
  * @return string[] Integer position => option path
  */
 private function showPlaceholderOptions(OptionList $defaults)
 {
     $i = 0;
     $numberPathMap = [];
     foreach ($defaults->getOptions() as $option) {
         // Remember the number for each option
         $numberPathMap[$i] = $option->getPath();
         $line = sprintf('[%d] %s default: <<yellow>>%s<<reset>>', $i, $option->getPath(), $this->castToString($option->getDefault()));
         $currentValue = $this->frontmatter->get($option->getPath());
         if ($currentValue !== null) {
             $line = sprintf('%s user: <<green>>%s<<reset>>', $line, $this->castToString($currentValue));
         }
         $this->stdio->outln($line);
         $this->stdio->outln('  - ' . $option->getDescription());
         $i++;
     }
     $this->stdio->outln();
     return $numberPathMap;
 }