-
-
Notifications
You must be signed in to change notification settings - Fork 15
[BUGFIX] Fix non-working short-options for "config" and "working-dir" #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these changes, Looks good to me
d520def
to
38dff10
Compare
packages/guides-cli/bin/guides
Outdated
@@ -47,11 +46,13 @@ if (is_file($projectConfig)) { | |||
echo 'Loading guides.xml from ' . $projectConfig . PHP_EOL; | |||
} | |||
// vendor folder was placed directly into the project directory | |||
$containerFactory->addConfigFile($projectConfig); | |||
if ($projectConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a more explicit check. I think this check should be !== False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a lax check on that to also evalute an empty string to false.
But I can change that to:
if ($projectConfig !== false && $projectConfig !== '')
(but that has more cognitive load to me...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I choose to use early returns as much as possible. which is a bit hard in this context as we do not have real functions in this file. We could abuse empty($projectConfig) === false
here. or a small namespaced function:
namespace phpDocumentor/guides {
function emptyOption(string|bool $path) {
if ($path === false) {
return true;
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be happy to implement it anyway you prefer, I don't have strong feelings about either approach. Personally I'd then rather use the if ($projectConfig !== false && $projectConfig !== '')
approach, because I find the namespace variant and the empty(...) variant even harder to quickly read 😇
... sidequest ahead...
I did try to optimize this actual code block in the CLI binary because the current way of loading and overloading guides.xml created a problem for us in render-guides. And it's really not a beautiful piece of loading code ;)
I wanted to actually adjust that "guides.xml" could be fetched from the default render location (which is "docs" in guides
and "Documentation" in render-guides
).
But I couldn't get that to work because of the tough mixture of Decorator and actual Console command and loading order (see TYPO3-Documentation/render-guides#421 (comment)). I abandoned that for the time being, since we got bigger fish to fry at this point than putting hours into this optimization ;)
Thanks a lot @garvinhicking! |
ffe0a18
to
e386a79
Compare
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
[1.x] Merge pull request #930 from garvinhicking/support-short-code
This adresses:
--config
and not-c
is parsed, same with--working-dir
(-w
)getcwd()
maybe returning false and I didn't want to obfuscate this statement with if-condititions; if you have suggestions to improve the type juggling here, tell me.