Repository navigation
Closed
Labels
Description
I am trying to parse something like this:
./esp device status
./esp device status $myId
./esp device add $myId
./esp device remove $myIdTo do so I am using this definition:
type DeviceIdArgs =
| [<Mandatory>] [<MainCommand>] Id of string
with
interface IArgParserTemplate with
member this.Usage =
match this with
| Id _ -> "Id of the device to remove"
[<RequireSubcommand>]
type DeviceArgs =
| [<CliPrefix(CliPrefix.None)>] Status of ParseResults<DeviceIdArgs>
| [<CliPrefix(CliPrefix.None)>] Remove of ParseResults<DeviceIdArgs>
| [<CliPrefix(CliPrefix.None)>] Add of ParseResults<DeviceIdArgs>
with
interface IArgParserTemplate with
member this.Usage =
match this with
| Status _ -> "lists all devices currently associated with your account"
| Remove _ -> "removes the device with the given id from your account, use * to remove all"
| Add _ -> "adds a new device with the given id, will return a registration token"
[<RequireSubcommand>]
type EspArgs =
| Version
| [<CliPrefix(CliPrefix.None)>] [<First>] Account of ParseResults<AccountArgs>
| [<CliPrefix(CliPrefix.None)>] [<First>] Device of ParseResults<DeviceArgs>
| [<CliPrefix(CliPrefix.None)>] [<First>] Firmware of ParseResults<FirmwareArgs>
with
interface IArgParserTemplate with
member this.Usage =
match this with
| Version -> "echos the version of this tool"
| Account _ -> "create a backend account, or login to one"
| Device _ -> "list/remove/... devices from your account"
| Firmware _ -> "upload and apply firmware"This almost works like I want it to. I want to make sure that the user needs to supply an id with the commands. That why I used the MandatoryArgument for the id in the DeviceIdArgs.
Currently ./esp device add is a valid command.
Reacted by Toby Smyth, Chester, Nate Guerin, Jordan Cannon, queil and Ivan Kuznetsov
Activity
vrobinson commentedon Jul 23, 2018
I am seeing this too:
I expect these to throw and write out the help:
Note that no arguments , --help, --version, sequence --help, and sequence --direction all work as expected:
Am I missing something in how I should be using the library? Or is this a bug?
jcmrva commentedon Aug 1, 2023
I tried adding
[<Mandatory>]to a few subcommands today and noticed it wasn't working, so I'd say this is still a bug. UsingPostProcessResultmakes an argument mandatory, so it's not too hard to work around.bartelink commentedon Dec 12, 2023
@jcmrva the chances are #192 will ship the fix (AFAICT it is the first nuget release that includes #127)
bartelink commentedon Dec 13, 2023
@jcmrva FYI 6.1.2 is on nuget
jcmrva commentedon Dec 13, 2023
Thank you!