[feat] Add fallback to shell's "read" command. #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have just been playing with minicli and I like it. The readme says:
I wondered why this is necessary here. We are in a CLI. So why not leverage the CLI for this functionality instead of fiddling with PHP extensions?
Added
This PR adds functionality to check if the PHP
readline
extension is available. If not, we fall back on the shell commandread
, or (tbd) throw and exception if none of the options are available.Todo / Thoughts
This is just a draft to visualise my idea and see if you are interested. If this is something you want to merge, the following things need to be done or considered:
match()
was used, but I am open to handling this differently. I chose to use the match because it is easy to add more cases. For example, if you are interested in merging this, I would add OS related checks.readline
andread
could return false (ornull
). As this is not covered in the existing code, I have not touched it yet. Opinions?