Replies: 2 comments 1 reply
-
It is! I'm not able to respond in much detail now, but effectively doing something like `(profileOpt, regionOpt, subcommand1 orElse subcommand2).mapN(...)` works and has the behaviour you desire.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
To elaborate a bit more: One final wrinkle to know about is that if you're using the "effect style", you'll generally end up with all your subcommands having a function type. One pattern some folks like is to come up with a special subcommand trait: trait Subcommand {
def run(profile: Profile, ...): IO[Unit]
}
val fooCommand: Opts[Subcommand] = ???
val profileOpt: Opts[Profile] = ???
(profileOpt, fooCommand).mapN((profile, sub) => sub.run(profile)) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The aws cli lets you do stuff like
where there are 200 subcommands, but
--profile
and--region
are shared across all of them. I know I can get close to this by creating opts for profile and region and just share them across all my subcommands. I don't love this solution though. Apart from all the code copying, they only show up in the help for the subcommand, but not the help for the top command. I was hoping there's a way to structure the cli likeIs this kind of thing possible today in Decline?
Beta Was this translation helpful? Give feedback.
All reactions