Skip to content

Releases: ajalt/clikt

4.0.0

04 Jul 18:53
Compare
Choose a tag to compare

Clikt 4.0 is a major release that uses the Mordant library for help formatting. If you aren't
customizing help output, this upgrade will probably be source compatible.

Highlights

Here are some of the highlights of this release. See CHANGELOG.md for a detailed list of changes.

Colors and Markdown in help output

All help strings now support markdown, including tables and lists. On terminals that support it,
help and error messages will be colored.

class Command : CliktCommand(
    help="""
    ## This command uses markdown for its help text
    
    - You can use lists
    - You can use **bold** and *italic* text
    - You can even use [links](https://example.com) on terminals that support them
    
    | You       | can    | use  | tables |
    |-----------|--------|------|--------|
    | and       | they   | will | be     |
    | formatted | nicely | for  | you    |
    """.trimIndent()
)
$ ./command --help
Usage: command [<options>]

───── This command uses markdown for its help text ─────

 • You can use lists
 • You can use bold and italic text
 • You can even use links on terminals that support them

┌───────────┬────────┬──────┬────────┐
│ You       │ can    │ use  │ tables │
╞═══════════╪════════╪══════╪════════╡
│ and       │ they   │ will │ be     │
├───────────┼────────┼──────┼────────┤
│ formatted │ nicely │ for  │ you    │
└───────────┴────────┴──────┴────────┘

There are new lazy extensions for setting paramter help that you can use to add color to parameter help text:

option().help { theme.info("this text will use the theme color") }

Optional and vararg values for options

You can now use optionalValue() to create an option that can be used as a flag or with a value

val log by option().optionalValue("verbose").default("none")
> ./tool --log=debug
log level == debug

> ./tool --log
log level == verbose

> ./tool
log level == none

You can also use varargValues() to create an option that accepts a variable number of values.

Streamlined error handling

Clikt's exceptions now all inherit from CliktError, and the CliktCommand.getFormattedHelp
method renders them into strings for you. This makes customizing main much easier. The default
implementation is now just:

fun main(argv: List<String>) {
    try {
        parse(argv)
    } catch (e: CliktError) {
        echoFormattedHelp(e)
        exitProcess(e.statusCode)
    }
}

4.0.0-RC

27 Jun 22:01
Compare
Choose a tag to compare
4.0.0-RC Pre-release
Pre-release

Clikt 4.0 is a major release that uses the Mordant library for help formatting. If you aren't
customizing help output, this upgrade will probably be source compatible.

Highlights

Here are some of the highlights of this release. See CHANGELOG.md for a detailed list of changes.

Colors and Markdown in help output

All help strings now support markdown, including tables and lists. On terminals that support it,
help and error messages will be colored.

class Command : CliktCommand(
    help="""
    ## This command uses markdown for its help text
    
    - You can use lists
    - You can use **bold** and *italic* text
    - You can even use [links](https://example.com) on terminals that support them
    
    | You       | can    | use  | tables |
    |-----------|--------|------|--------|
    | and       | they   | will | be     |
    | formatted | nicely | for  | you    |
    """.trimIndent()
)
$ ./command --help
Usage: command [<options>]

───── This command uses markdown for its help text ─────

 • You can use lists
 • You can use bold and italic text
 • You can even use links on terminals that support them

┌───────────┬────────┬──────┬────────┐
│ You       │ can    │ use  │ tables │
╞═══════════╪════════╪══════╪════════╡
│ and       │ they   │ will │ be     │
├───────────┼────────┼──────┼────────┤
│ formatted │ nicely │ for  │ you    │
└───────────┴────────┴──────┴────────┘

Optional and vararg values for options

You can now use optionalValue() to create an option that can be used as a flag or with a value

val log by option().optionalValue("verbose").default("none")
> ./tool --log=debug
log level == debug

> ./tool --log
log level == verbose

> ./tool
log level == none

You can also use varargValues() to create an option that accepts a variable number of values.

Streamlined error handling

Clikt's exceptions now all inherit from CliktError, and the CliktCommand.getFormattedHelp
method renders them into strings for you. This makes customizing main much easier. The default
implementation is now just:

fun main(argv: List<String>) {
    try {
        parse(argv)
    } catch (e: CliktError) {
        echoFormattedHelp(e)
        exitProcess(e.statusCode)
    }
}

3.5.4

20 Jun 17:57
Compare
Choose a tag to compare

Fixed

  • Revert JVM jars to compile with Java 8 bytecode

3.5.3

19 Jun 18:07
Compare
Choose a tag to compare

Changed

  • Updated Kotlin to 1.8.22

Fixed

  • Context is now set properly on NoSuchOption exceptions when thrown from subcommands. (#399)
  • When treatUnknownOptionsAsArgs is true, grouped unknown short options will now be treated as arguments rather than reporting an error.

3.5.2

26 Feb 20:20
Compare
Choose a tag to compare

Changed

  • Updated Kotlin to 1.8.10

Fixed

  • Fix CliktCommand.prompt on NodeJS targets that would hang due to KT-55817 (#387)

3.5.1

27 Dec 21:36
Compare
Choose a tag to compare

Fixed

  • Support unicode in environment variable values on Native Windows. (#362)
  • Support environment variables for options in a mutually exclusive options group. (#384)

3.5.0

12 Jun 16:50
Compare
Choose a tag to compare

Added

  • Added hidden parameter to CliktCommand, which will prevent the command from being displayed as a subcommand in help output (#353)
  • Publish artifacts for the macosArm64 target. Note that this target is not tested on CI. (#352)

Changed

  • Default values for arguments will now be included in help output when showDefaultValues=true is set on your help formatter (#357)

Fixed

  • Fix flags and other options with defaults not being usable in mutuallyExclusiveOptions (#349)
  • Fix CompletionCommand generating completion for itself (#355)

3.4.2

25 Apr 03:58
Compare
Choose a tag to compare

Deprecated

  • TermUi.echo, TermUi.prompt, and TermUi.confirm. Use the equivalent methods on CliktCommand instead. (#344)

3.4.1

09 Apr 17:34
Compare
Choose a tag to compare

Added

  • Publish JS artifacts with new IR compiler, in addition to the legacy format

Changed

  • Updated Kotlin to 1.6.20

3.4.0

16 Jan 21:10
Compare
Choose a tag to compare

Changed

  • Updated Kotlin to 1.6.10
  • unique() now works with any option with a list type, not just multiple() options (#332)

Fixed

  • Fixed co-occurring option groups returning null when all options in the group are defined in environment variables (#330)