Phil Richardson
03/21/2022, 7:38 PMAJ Alt
03/21/2022, 8:08 PMjw
10/25/2022, 3:09 PM./cli --> null
./cli --foo --> default (a)
./cli --foo=a --> a
./cli --foo=b --> b
Sebastian Schuberth
12/07/2022, 9:27 PMBig Chungus
01/11/2023, 12:07 AM-h
)? I'm writing a cli that has an interpreter command which needs to propagate all args, but anything starting wit -h
(e.g. -hidon'treallywanthelp
) gets eaten up and produces illegal option error.
I'm aware of --
and it works, but I'm wondering if there's a way to somehow hack CliktCommand to avoid having that (this particular command is hidden and is reserved for internal use anyways).Big Chungus
01/30/2023, 5:32 PMjw
01/30/2023, 5:38 PMjeff
02/01/2023, 5:26 PMscript --some-option="two words"
sets --some-option
to two
and then passes words
as an argumentJim
03/14/2023, 3:06 AMSebastian Schuberth
04/19/2023, 9:21 PM--dry-run
flag. If it's specified, the output directory does not have to be specified (via -o
), but it can be specified (as it will not be written to anyway).Daniel
04/27/2023, 7:53 AMfun main(args: Array<String>) = Launcher.subcommands(InitKeystore).main(args)
object Launcher : CliktCommand(help = "", invokeWithoutSubcommand = true) {
...
override fun run() {
...
log("I have done something")
}
}
object InitKeystore : CliktCommand(name = "keystore_init", help = "") {
...
override fun run() {
...
log("I have done init")
}
}
When I run it without the keystore_init
subcommand, it launches correctly only the Launcher
, but when I specify the keystore_init
subcommand, I see in my output both the log strings, ie. it runs the main command and then the subcommand ?Paul Woitaschek
07/21/2023, 7:32 AMcurioustechizen
07/28/2023, 2:19 PMted
09/16/2023, 1:21 PMclass Hello : CliktCommand() {
val count: Int by option().int().default(1).help("Number of greetings")
val name: String by option().prompt("Your name").help("The person to greet")
override fun run() {
repeat(count) {
echo("Hello $name!")
}
}
}
fun main(args: Array<String>) = Hello().main(args)
source
I can run it from intellij but how do I create the executable ./hello
?Marc Plano-Lesay
11/09/2023, 11:04 AM--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?Simon Marquis
11/14/2023, 11:09 AMmultiple()
and prompt()
to allow the user to provide values at runtime if nothing is provided.
Unfortunately, this does not seem to be supported.
What would be the recommended way to support this kind of behavior?
I'm currently using this, but this prevent me from using a prompt
val flavors: Set<Flavor> by option("-f", "--flavors")
.enum<Flavor>(ignoreCase = true)
.multiple(default = listOf(Main)).unique()
Eugen Martynov
02/05/2024, 11:53 AMAdam S
03/14/2024, 9:49 AMhttps://github.com/ajalt/clikt/blob/4.2.2/docs/img/animation.png▾
ted
03/18/2024, 4:31 PMsuresh
05/19/2024, 10:59 AM2.6.0
? I have a gradle build script which uses just the TextColors
and it’s broke after updating to 2.6.0. Things started working fine after adding mordant-coroutines.efemoney
09/16/2024, 12:08 PMkyle
10/01/2024, 9:13 PMandries.fc
11/28/2024, 12:41 PM--schema
with the --schema-script
:
--schema accounting --schema-script accounting.sql --schema salestracking --schema-script salestracking.sql
Adam Brown
12/02/2024, 8:45 AMval progressLayout = progressBarLayout {
spinner(Spinner.Dots())
marquee(terminal.theme.warning("Running conversion"), width = 24, align = TextAlign.CENTER)
percentage()
progressBar()
completed(style = terminal.theme.success)
}
val progress = progressLayout.animateInCoroutine(t)
t.println(
Panel(
expand = true,
content = horizontalLayout {
column(0) { width = Expand(1) }
column(1) {
width = Auto
}
column(2) { width = Expand(1) }
cell(EmptyWidget)
cell(
table {
captionTop("Input Dictionary")
body {
row("Input File", path.name)
row("Size", inputMetadata.size.toString() + " Bytes")
row("Entries", numEntries)
row {
cell(
progressLayout.build(null, 0, TimeSource.Monotonic.markNow())
) {
columnSpan = 2
}
}
}
}
)
cell(EmptyWidget)
},
title = Text("FDIC Converter")
)
)
val scope = CoroutineScope(Dispatchers.Default)
scope.launch { progress.execute() }
Adam Brown
12/02/2024, 6:22 PMAdam Brown
12/04/2024, 1:28 AMsuresh
12/21/2024, 5:07 AM> Task :backend:native:linkDebugTestLinuxX64 FAILED
The /home/runner/.konan/dependencies/llvm-16.0.0-x86_64-linux-essentials-80/bin/ld.lld command returned non-zero exit code: 1.
output:
ld.lld: error: duplicate symbol: kfun:com.github.ajalt.clikt.core#selfAndAncestors__at__com.github.ajalt.clikt.core.Context(){}kotlin.sequences.Sequence<com.github.ajalt.clikt.core.Context>
>>> defined at Context.kt:0 (/home/runner/work/clikt/clikt/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/core/Context.kt:0)
>>> libclikt:clikt-cache.a.o:(kfun:com.github.ajalt.clikt.core#selfAndAncestors__at__com.github.ajalt.clikt.core.Context(){}kotlin.sequences.Sequence<com.github.ajalt.clikt.core.Context>) in archive /home/runner/.konan/kotlin-native-prebuilt-linux-x86_64-2.1.20-Beta1/klib/cache/linux_x64-gSTATIC-pl/clikt:clikt/2bx6m2c1bk30f.1y4oy7igjc182/clikt:clikt-cache/bin/libclikt:clikt-cache.a
>>> defined at MordantContext.kt:0 (/home/runner/work/clikt/clikt/clikt-mordant/src/commonMain/kotlin/com/github/ajalt/clikt/core/MordantContext.kt:0)
>>> libclikt:clikt-mordant-cache.a.o:(.text.kfun:com.github.ajalt.clikt.core#selfAndAncestors__at__com.github.ajalt.clikt.core.Context(){}kotlin.sequences.Sequence<com.github.ajalt.clikt.core.Context>+0x0) in archive /home/runner/.konan/kotlin-native-prebuilt-linux-x86_64-2.1.20-Beta1/klib/cache/linux_x64-gSTATIC-pl/clikt:clikt-mordant/3uo87q16hlqb.wo5fwkyzrtn4/clikt:clikt-mordant-cache/bin/libclikt:clikt-mordant-cache.a
Michael Friend
01/14/2025, 8:08 PMclass Pickle : SuspendingCliktCommand() {
val config by option(eager = true)
.file()
init {
context {
config?.let {
valueSources(PropertiesValueSource.from(it))
}
}
}
val test by option()
override suspend fun run() {
echo(test)
}
}
Rob Elliot
02/26/2025, 4:35 PMmutuallyExclusiveOptions
where one of the options is an OptionGroup
? Intuitively it seems like it should be possible, but I can't work out the syntax!Rob Elliot
04/01/2025, 1:47 PM