refactor(scoop-shim): Use getopt
to parse arguments
#5125
Merged
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.
Description
Use
getopt
to parse arguments, which avoids some problems. BTW, add some logic and tweak some error messages.Motivation and Context
These problems will be resolved:
For example, run
scoop shim add myapp ''
, the second parameter (<command_path>
) gets an empty value, so Scoop will throw an exception, which is not so friendly. :For example, run
scoop shim list *
, the regex pattern*
is invalid, so Scoop will throw an exception, which is not so friendly. :The
-g
/--global
option cannot be parsed inscoop shim ...
. See [Bug]scoop shim info : ERROR: Option -global not recognized. #5094.How Has This Been Tested?
Now with this:
scoop shim add myapp ''
shows an error:scoop shim list *
shows an error:To create a local shim
myapp
witharg
and--global
as arguments:Note that we have to use a QUOTED command option terminator (
'--'
) in PowerShell CLI.To create a global shim
myapp
witharg
as the argument:No major changes to other subcommands.
Checklist:
develop
branch.