https://kotlinlang.org logo
#clikt
Title
# clikt
m

Marc Plano-Lesay

11/09/2023, 11:04 AM
Is there a way to somehow split the top-level command and subcommands in two distinct phases? I'd like to leverage the top-level command for generic arguments (e.g. a
--verbose
flag), that I could then inject through Dagger in different subcommands. But from what I understand of Clikt's subcommands, I'd need to have them initialised before the parent's parsing is done, I believe?
s

Sebastian Schuberth

11/10/2023, 12:03 PM
We're doing something like that with "global" onfig CLI options that are passed to subcommands via the context. No need for a DI framework here: https://github.com/oss-review-toolkit/ort/blob/17f3ad103edfbe03a1d4b2189524de89ba0c5ef1/cli/src/main/kotlin/OrtMain.kt#L148-L150