You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible with the current state of the API to share options/arguments with subcommands?
Example:
I have two subcommands, which process either a) a single file or b) a set of files contained in multiple directories.
Naturally I created two subcommands:
classSingle(privatevalrunner:Runner) : Subcommand("single", "Process a single file") {
privateval file by argument(
type =ArgType.String,
fullName ="file",
description ="Process the given file."
)
overridefunexecute() {
runner.single(File(file))
}
}
classMultiple(privatevalrunner:Runner) : Subcommand("multiple", "Process all files in the given directories") {
privateval directories by argument(
type =ArgType.String,
fullName ="directories",
description ="Process all files in the given directory or directories."
).vararg()
overridefunexecute() {
runner.multiple(directories.map(::File))
}
}
What I'd like to do is have both subcommands be able to access a shared -o --output option to specify the output directory.
privateval output by option(
type =ArgType.String,
shortName ="o", fullName ="output",
description ="Specify the output directory"
).default(".")
At the moment it seems like I have to duplicate this in each subcommand for this to work.
The text was updated successfully, but these errors were encountered:
Is it possible with the current state of the API to share options/arguments with subcommands?
Example:
I have two subcommands, which process either a) a single file or b) a set of files contained in multiple directories.
Naturally I created two subcommands:
What I'd like to do is have both subcommands be able to access a shared
-o --output
option to specify the output directory.At the moment it seems like I have to duplicate this in each subcommand for this to work.
The text was updated successfully, but these errors were encountered: