From 8ad1d10a7894c1cd482a48234cb571e8cddfbdb2 Mon Sep 17 00:00:00 2001 From: Jordan LeDoux Date: Thu, 8 Jul 2021 04:13:07 -0700 Subject: [PATCH] Addresses #8: Issues with first time run --- src/Samsara/Roster/Roster.php | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/Samsara/Roster/Roster.php b/src/Samsara/Roster/Roster.php index e57d681..16e543f 100644 --- a/src/Samsara/Roster/Roster.php +++ b/src/Samsara/Roster/Roster.php @@ -135,13 +135,22 @@ protected function configure(): void } foreach ($options as $name => $option) { - $this->addOption( - name: $name, - shortcut: $option['shortcut'], - mode: $option['mode'], - description: $option['description'], - default: $option['default'] - ); + if (array_key_exists('default', $option)) { + $this->addOption( + name: $name, + shortcut: $option['shortcut'], + mode: $option['mode'], + description: $option['description'], + default: $option['default'] + ); + } else { + $this->addOption( + name: $name, + shortcut: $option['shortcut'], + mode: $option['mode'], + description: $option['description'] + ); + } } } @@ -171,7 +180,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $configPathRoot = $this->rootDir.'/'.$opts['config-file']; - $configPathVendor = $this->rootRosterDir.'/'.$opts['config-file']; if (!is_file($configPathRoot)) { ConfigBag::setRosterConfig(new Config("{}", new Json(), true)); @@ -234,11 +242,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int ConfigBag::getRosterConfig()->set('templates', 'doc-templates/roster-templates'); } - if (isset($opts['prefer-source']) || !ConfigBag::getRosterConfig()->has('prefer-source')) { + if ($opts['prefer-source'] || !ConfigBag::getRosterConfig()->has('prefer-source')) { ConfigBag::getRosterConfig()->set('prefer-source', $opts['prefer-source'] ?? false); } - if (isset($opts['mkdocs']) && !ConfigBag::getRosterConfig()->has('mkdocs')) { + if ($opts['mkdocs'] && !ConfigBag::getRosterConfig()->has('mkdocs')) { ConfigBag::getRosterConfig()->set('mkdocs', []); } @@ -562,7 +570,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $oldConfig->set('site_name', ConfigBag::getRosterConfig()->get('mkdocs.site-name', $oldConfig->get('site_name'))); $oldConfig->set('site_url', ConfigBag::getRosterConfig()->get('mkdocs.site-url', $oldConfig->get('site_url'))); - $oldConfig->set('repo_url', ConfigBag::getRosterConfig()->get('mkdocs.site-repo', $oldConfig->get('repo_url'))); + $oldConfig->set('repo_url', ConfigBag::getRosterConfig()->get('mkdocs.repo-url', $oldConfig->get('repo_url'))); $oldConfig->set('nav', $oldNav); $oldConfig->set('extra_css', $extraCss); $mkDocsConfig = (new YamlDumper(4))->dump($oldConfig->all(), 50, 0, Yaml::DUMP_OBJECT_AS_MAP); @@ -585,7 +593,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $configBase->set('site_name', ConfigBag::getRosterConfig()->get('mkdocs.site-name')); $configBase->set('site_url', ConfigBag::getRosterConfig()->get('mkdocs.site-url')); - $configBase->set('repo_url', ConfigBag::getRosterConfig()->get('mkdocs.site-repo')); + $configBase->set('repo_url', ConfigBag::getRosterConfig()->get('mkdocs.repo-url')); $configBase->set('nav', $formattedNav); $configBase->set('extra_css', $extraCss);