Repository navigation
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Summary of the new feature/enhancement
Need discuss before pulling RFC and find most appropriate form.
Today we have the ability to describe parameters and parameter sets in cmdlets using attributes Parameter(ParameterSetName = "name").
This works well for small and simple parameter sets.
In the case of the definition of more complex variants, this turns into a puzzle.
Proposed technical implementation details
Notation http://docopt.org/
For reference https://docs.python.org/2/howto/argparse.html
[-Param1 [-OptionalParam11 | -OptionalParam12] | -Param2]
(-Param1 -ParamMandatoryforParam1 [-OptionalParam11 | -OptionalParam12] | -Param2)
Initial sample based on Test-Connection cmdlet:
[Cmdlet(VerbsDiagnostic.Test, "Connection", DefaultParameterSetName = ParameterSetPingCount, HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135266")]
[OutputType(typeof(PingReport), ParameterSetName = new string[] { ParameterSetPingCount })]
[OutputType(typeof(PingReply), ParameterSetName = new string[] { ParameterSetPingContinues, ParameterSetDetectionOfMTUSize })]
[OutputType(typeof(bool), ParameterSetName = new string[] { ParameterSetPingCount, ParameterSetPingContinues, ParameterSetConnectionByTCPPort })]
[OutputType(typeof(Int32), ParameterSetName = new string[] { ParameterSetDetectionOfMTUSize })]
[OutputType(typeof(TraceRouteReply), ParameterSetName = new string[] { ParameterSetTraceRoute })]
[ParameterSet(
Name = ParameterSetPingCount, // Optional
Positional(nameof(TargetName), nameof(Count)),
ParameterList(
Parameter(Name = nameof(Ping)),
MutuallyExclusiveGroup(
nameof(IPv4), // First is default
nameof(IPv6),
Parameter(nameof(IPv7),
MutuallyExclusiveGroup(
nameof(ParForIPv7_A),
nameof(ParForIPv7_B)
)
)
),
nameof(ResolveDestination),
nameof(Source),
nameof(MaxHops),
nameof(Count),
nameof(Delay),
nameof(BufferSize),
nameof(DontFragment),
nameof(Quiet),
nameof(TimeoutSeconds),
Parameter(Name = nameof(TargetName), Mandatory = true)
)
)]
[ParameterSet(
Name = ParameterSetPingContinues,
Parameters(
Parameter(Name = nameof(Ping)),
MutuallyExclusiveGroup(
nameof(IPv4),
nameof(IPv6)
),
nameof(ResolveDestination),
nameof(Source),
nameof(MaxHops),
Parameter(Name = nameof(Continues), Mandatory = true,
nameof(Delay),
nameof(BufferSize),
nameof(DontFragment),
nameof(Quiet),
nameof(TimeoutSeconds),
Parameter(Name = nameof(TargetName), Mandatory = true)
)
)]
[ParameterSet(
Name = TraceRoute,
Parameters(
Parameter(Name = nameof(Traceroute), Mandatory = true),
MutuallyExclusiveGroup(
nameof(IPv4),
nameof(IPv6)
),
nameof(ResolveDestination),
nameof(Source),
nameof(MaxHops),
nameof(Quiet),
nameof(TimeoutSeconds),
Parameter(Name = nameof(TargetName), Mandatory = true)
)
)]
public class TestConnectionCommand : PSCmdlet
{Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Activity