Releases: ajalt/clikt
5.0.3
5.0.2
5.0.1
5.0.0
This release splits the package into separate modules to help produce smaller binaries. Parsing and running commands are now separated, which allows for custom run types. This release includes the SuspendingCliktCommand and the ChainedCliktCommand, and it's easy to define your own.
See the migration guide for details on upgrading to Clikt 5.0.
Added
- Publish
iosArm64andiosX64targets. - Added
NoSuchArgumentexception that is thrown when too many arguments were given on the command line. Previously, a less specificUsageErrorwas thrown instead. - Added
CommandLineParser.tokenizethat splits a string into argv tokens. - Added
CommandLineParserthat provides functions for parsing and finalizing commands manually for more control. - Added
Context.invokedSubcommandsthat contains all subcommands of the current command that are going to be invoked whenallowMultipleSubcommandsistrue. - Added
SuspendingCliktCommandthat has asuspend fun runmethod, allowing you to use coroutines in your commands. - Added
ChainedCliktCommandthat allows you to return a value from yourrunmethod and pass it to the next command in the chain. - Added
Context.dataas an alternative toobjthat allows you to store more than one object in the context. - Added
Context.echoerto customize howechomessages are printed. - Added
CompletionGeneratorto manually generate completions for a command. - Added
Context.exitProcesswhich you can use to prevent the process from exiting during tests. - Added core module that supports watchOS, tvOS, and wasmWasi targets and has no dependencies.
- Added more options to
CliktCommand.testto control the terminal interactivity. (#517) - Added
associate{},associateBy{}, andassociateWith{}transforms for options that allow you to convert the keys and values of the map. (#529) - Added support for aliasing options to other options. (#535)
- Added
limitandignoreCaseparameters tooption().split(). (#541) - Support calling
--helpon subcommands when parents have required parameters.
Changed
-
In a subcommand with and an
argument()withmultiple()oroptional(), the behavior is now the same regardless of the value ofallowMultipleSubcommands: if a token matches a subcommand name, it's now treated as a subcommand rather than a positional argument. -
Due to changes to the internal parsing algorithm, the exact details of error messages when multiple usage errors occur have changed in some cases.
-
Breaking Change: Moved the following parameters from
CliktCommand's constructor; override the corresponding properties instead:removed parameter replacement property helpfun helpepilogfun helpEpiloginvokeWithoutSubcommandval invokeWithoutSubcommandprintHelpOnEmptyArgsval printHelpOnEmptyArgshelpTagsval helpTagsautoCompleteEnvvarval autoCompleteEnvvarallowMultipleSubcommandsval allowMultipleSubcommandstreatUnknownOptionsAsArgsval treatUnknownOptionsAsArgshiddenval hiddenFromHelp -
The following methods on
CliktCommandhave been renamed:commandHelp->help,commandHelpEpilog->epilog. The old names are deprecated. -
Breaking Change:
CliktCommand.mainandCliktCommand.parseare now extension functions rather than methods. -
Breaking Change:
Context.objandContext.terminal, andOptionTransformContext.terminalare now extension functions rather than properties. -
Breaking Change: The
RenderedSectionandDefinitionRowclasses have moved toAbstractHelpFormatter. -
Markdown support in the help formatter is no longer included by default. To enable it, include the
:clikt-markdowndependency and callyourCommand.installMordantMarkdown()before parsing. -
Updated Kotlin to 2.0.0
Fixed
- Fixed excess arguments not being reported when
allowMultipleSubcommands=trueand a subcommand has excess arguments followed by another subcommand. - Commands with
printHelpOnEmptyArgs=truewill no longer print help if an option has a value from an environment variable or value source. (#382)
Deprecated
- Deprecated
Context.originalArgv. It will now always return an empty list. If your commands need an argv, you can pass it to them before you run them, or set in on the newContext.datamap. - Deprecated
Context.expandArgumentFiles. UseContext.argumentFileReaderinstead. - Renamed the following
Contextfields to be more consistent. The old names are deprecated.
| old name | new name |
|---|---|
Context.envvarReader |
Context.readEnvvar |
Context.correctionSuggestor |
Context.suggestTypoCorrection |
Context.argumentFileReader |
Context.readArgumentFile |
Context.tokenTransformer |
Context.transformToken |
Removed
- Removed previously deprecated experimental annotations.
- Removed
MordantHelpFormatter.graphemeLength - Removed
TermUi
4.4.0
4.3.0
Added
- Added
limitparameter tooption().counted()to limit the number of times the option can be used. You can either clamp the value to the limit, or throw an error if the limit is exceeded. (#483) - Added
Context.registerClosableandContext.callOnCloseto allow you to register cleanup actions that will be called when the command exits. (#395)
Fixed
4.2.2
4.2.1
Added
- Added
toStringimplementations to options and arguments. (#434) - Added
CliktCommand.testoverload that takes a vararg ofStrings as the command line arguments. Thanks to @sschuberth for the contribution (#451)
Fixed
- Update Mordant dependency to fix crashes on native targets and GraalVM (#447)
4.2.0
Added
- Added
requireConfirmationparameter tooption().prompt()(#426) - Added
CliktCommand.terminalextension for accessing the terminal from a command. - Added
includeSystemEnvvars,ansiLevel,width, andheightparameters to allCliktCommand.testoverloads.
Deprecated
- Deprecated
CliktCommand.prompt, useCliktCommand.terminal.promptorPromptinstead. - Deprecated
CliktCommand.confirm, useYesNoPromptinstead.
4.1.0
Added
- Added
MordantHelpFormatter.renderAttachedOptionValuethat you can override to change how option values are shown, e.g. if you want option to show as--option <value>instead of--option=<value>. (#416) - Added
option().optionalValueLazy{}, which work likeoptionalValue()but the default value is computed lazily. (#381)
Changed
- Updated Kotlin to 1.9.0
PrintMessage,PrintHelpMessageandPrintCompletionMessagenow default to exiting with a status code 0, which is the behavior they had in 3.x. (#419)