Reputation: 6111
How can one create a powershell module that can be called like npm or git ?
Example:
git commit SomeFile.py
Git is the powershell module you want to use. Commit is the action you want to execute And then you have a list of arguments.
Is this possible?
Upvotes: 0
Views: 30
Reputation: 174435
Create a param block with 2 parameters:
1 parameter that has Position=0
, and 1 that supports ValueFromRemainingArguments
:
function gitlike
{
param(
[Parameter(Mandatory,Position=0)]
[ValidateSet('commit','pull','push','status','etc')]
[string]$Command,
[Parameter(ValueFromRemainingArguments)]
[string[]]$Arguments
)
# parse $Arguments in here
# or
# Invoke-YourCommandSpecificThing @Arguments
}
Upvotes: 2