2020-12-12
- Added
required()
anddefaultLazy()
for nullable flag options likeswitch()
. (#240) - Added support for generating autocomplete scripts for Fish shells (#189)
- Added
CompletionCommand
andCliktCommand.completionOption()
that will print an autocomplete script when invoked, as an alternative to using environment variables.
- Updated Kotlin to 1.4.21
@argfiles
now allow line breaks in quoted values, which are included in the value verbatim. You can now end lines with\
to concatenate them with the following line. (#248)
2020-09-03
- Deprecated calling
echo
witherr
orlineSeparator
but nomessage
.
2020-09-02
- Clikt's JS target now supports both NodeJS and Browsers. (#198)
- Default values for switch options are now shown in the help. Help text can be customized using the
defaultForHelp
argument, similar to normal options. (#205) - Added
FlagOption.convert
(#208) - Added ability to use unicode NEL character (
\u0085
) to manually break lines in help output (#214) - Added
help("")
extension to options and arguments as an alternative to passing the help as an argument (#207) - Added
valueSourceKey
parameter tooption
- Added
check()
extensions to options and arguments as an alternative tovalidate()
- Added
prompt
andconfirm
functions toCliktCommand
that call theTermUi
equivalents with the current console. - Added
echo()
overload with no parameters to CliktCommand that prints a newline by itself. - Added localization support. You can set an implementation of the
Localization
interface on your context with your translations. (#227)
- Hidden options will no longer be suggested as possible typo corrections. (#202)
- Options and Arguments with
multiple(required=true)
will now show as required in help output. (#212) - Multiple short lines in a help text paragraph no longer appear dedented (#215)
- Updated Kotlin to 1.4.0
Argument.help
andOption.help
properties have been renamed toargumentHelp
andoptionHelp
, respectively. Thehelp
parameter names tooption()
andargument()
are unchanged.commandHelp
andcommandHelpEpilog
properties onCliktCommand
are nowopen
, so you can choose to override them instead of passinghelp
andepilog
to the constructor.- Replaced
MapValueSource.defaultKey
withValueSource.getKey()
, which is more customizable. Option.metavar
,Option.parameterHelp
,OptionGroup.parameterHelp
andArgument.parameterHelp
properties are now functions.- Changed constructor parameters of
CliktHelpFormatter
. Addedlocalization
and removedusageTitle
,optionsTitle
,argumentsTitle
,commandsTitle
,optionsMetavar
, andcommandMetavar
. Those strings are now defined on equivalently named functions onLocalization
.
- Removed
envvarSplit
parameter fromoption()
andconvert()
. Option values from environment variables are no longer split automatically. (#177) - Removed public constructors from the following classes:
ProcessedArgument
,OptionWithValues
,FlagOption
,CoOccurringOptionGroup
,ChoiceGroup
,MutuallyExclusiveOptions
. MissingParameter
exception replaced withMissingOption
andMissingArgument
- Removed
Context.helpOptionMessage
. OverrideLocalization.helpOptionMessage
and set it on your context instead.
@ExperimentalCompletionCandidates
and@ExperimentalValueSourceApi
annotations. These APIs no longer require an opt-in.
2020-06-19
- Added
error
parameter toPrintMessage
andPrintHelpMessage
. Whentrue
,CliktCommand.main
will exit with status code 1. (#187)
- When
printHelpOnEmptyArgs
istrue
and no arguments are present, or wheninvokeWithoutSubcommand
isfalse
and no subcommand is present,CliktCommand.main
will now exit with status code 1 rather than 0. restrictTo
now works with anyComparable
value, not justNumber
.CliktCommand.main
now acceptsArray<out String>
, not justArray<String>
. (#196)
- Fixed option values being reset when calling multiple subcommands with
allowMultipleSubcommands=true
(#190)
2020-05-19
- Fixed NPE thrown in some cases when using
defaultByName
(#179)
2020-05-13
- Ability to use custom program exit status codes via
ProgramResult
. inputStream
andoutputStream
conversions for options and arguments. (#157 and #159)splitPair
,toMap
, andassociate
extensions onoption
. (#166)treatUnknownOptionsAsArgs
parameter toCliktCommand
. (#152)defaultByName
function forgroupChoice
andgroupSwitch
options. (#171)
- Update Kotlin to 1.3.71
- Improved command name inference. Now, a class like
MyAppCommand
will infer itscommandName
asmy-app
rather thanmyappcommand
. You can still specify the name manually as before. ([#168][ajalt#168])
- Correctly parse short options with attached values that contain
=
2020-03-15
registeredSubcommands
,registeredOptions
,registeredArguments
, andregisteredParameterGroups
methods onCliktCommand
.- Ability to read default option values from configuration files and other sources. Support for Java property files is built in on JVM, see the
json
sample for an example of reading from other formats. allowMultipleSubcommands
parameter toCliktCommand
that allows you to pass multiple subcommands in the same call. (docs)- Errors from typos in subcommand names will now include suggested corrections. Corrections for options and subcommands are now based on a Jaro-Winkler similarity metric, and can be customized with
Context.correctionSuggestor
- Update Kotlin to 1.3.70
convert
can be called more than once on the same option or argument, including after calls to conversion functions likeint
andfile
.CliktCommand.toString
now includes the class name- Reverted automatic
~
expansion infile()
andpath()
introduced in 2.5.0. If you need this behavior, you can implement it with code likeconvert { /* expand tidle */ }.file()
wrapValue
is now deprecated, sinceconvert
can be used in its place instead.
2020-02-22
- Clikt is now available as a Kotlin Multiplatform Project, supporting JVM, NodeJS, and native Windows, Linux, and macOS.
eagerOption {}
function to more easily register eager options.- Eager options can now be added to option groups in help out by passing a value for
groupName
when creating them. canBeSymlink
parameter tofile()
andpath()
conversions that can be used to disallow symlinksCliktCommand.eagerOption
to simplify creating custom eager options
- The parameter names of
file()
andpath()
conversions have changed. The existing names are deprecated, and can be converted to the new usages with an IntelliJ inspection. Note that if you are calling these functions with unnamed arguments (e.g.file(true, false)
), you'll need to add argument names in order to remove the deprecation warning.
- The
CliktCommand.context
property has been deprecated in favor of the new name,currentContext
, to avoid confusion with theCliktCommand.context{}
method. NoRunCliktCommand
was renamed toNoOpCliktCommand
. The existing class is deprecated. (#130)
file()
andpath()
conversions will now properly expand leading~
in paths to the home directory formustExist
,canBeFile
, andcanBeDir
checks. The property value is unchanged, and can still begin with a~
. (#131)
2020-01-25
CompletionCandidates.Fixed
now has a secondary convenience constructor that take avararg
ofString
sCompletionCadidates.Custom
, which allows you to call other binaries or write a script to generate completions. This class is currently experimental. (#79)Option.wrapValue
andArgument.wrapValue
to make it easier to reuse existing conversion functions.ignoreCase
parameter tochoice()
andenum()
conversion functions.
option()
andargument()
now take optionalcompletionCandidates
parameters to override how completion is generated. The constructor andcopy
functions ofOptionsWithValues
andProcessedArgument
have changed to support default values.- The overloads of
findObject
(1 2) that take a default value have been renamedfindOrSetObject
. The existing names are marked with@Deprecated
, and IntelliJ can convert your callsites automatically. (#110) enum()
parameters now accept case-insensitive values by default. You change this behavior by passingignoreCase = false
toenum()
(#115)
groupChoice
help output now includes the choices in the help output metavarTermUi.edit*
functions could freeze on certain editors (#99, thanks @iampravikant and @sebokopter)- Shell completion can now handle command names with dashes. (#104)
- Arguments with
=
in them could be incorrectly interpreted as options (#106)
2019-11-07
option().groupSwitch()
, which works likegroupChoice()
, but uses aswitch()
option rather than achoice()
option.UsageError
now has astatusCode
parameter (which defaults to 1). If you're usingClicktCommand.main
, the value ofstatusCode
will be passed toexitProcess
.
- Shell completion code is now printed by throwing a
PrintCompletionMessage
(a subclass ofPrintMessage
) rather than callingecho
directly.
2019-09-25
- Added
enum()
conversion for options and arguments. (#84)
- There are now several ways of preventing @-file expansion
- Help output missing items when no help text is specified. (#85)
- Help output not grouping options in groups passed to
groupChoice
. (#88)
2019-05-23
- Ability to prevent rewrapping individual paragraphs in help output.
- Added parameter
required
toOption.multiple()
to require at least one instance of the option on the command line.
CliktCommand.toString()
now includes the names and values of all parameters and subcommands.
- Create subcommand context when
helpOptionNames
is empty. (#64)
2019-05-12
- Bash autocomplete script generation. A property named
completionCandidates
has been added toArgument
andOption
interfaces, and corresponding parameters have been added to the various implementation constructors, as well as theconvert
functions. You can use this to control the values autocomplete that will be suggested. option().split()
, and the correspondingOptionWithValues.valueSplit
.- Marking options as deprecated with
option().deprecated()
- You can manually set the pattern to split envvars on by passing a pattern to the
envvarSplit
parameter ofoption()
- Option groups, mutually exclusive groups, co-occurring groups, and choice options with groups
- Support for Command line argument files a.k.a "@-files"
- If multiple
--
tokens are present on the command line, all subsequent occurrences after the first are now parsed as positional arguments. Previously, subsequent--
tokens were skipped. - The
PlaintextHelpFormatter
has been replaced withCliktHelpFormatter
, which is more customizable. See the docs for more info, or the new sample for an example of customizing help output to use ANSI colors. - Some of the properties and constructor parameters for
OptionWithValues
andProcessedArgument
have changed. - The
OptionDelegate
interface has changed, andGroupableOption
andParameterHolder
interfaces have been added to work with option groups. - Parameter validation now occurs after all parameter delegates have set their values, so the lambdas passed to
validate
may reference other parameters.
2019-03-23
printHelpOnEmptyArgs
parameter toCliktCommand
constructor. (#41)
- Usage errors now correctly print subcommand names. (#47)
- Arguments with
multiple(required=true)
now report an error if no argument is given on the command line. (#36)
2018-12-02
.multiple().unique()
modifier for options and arguments.
- Support multi-line input when redirecting stdin
2018-08-26
- Ability to use alternate output streams rather than stdin and stdout by setting
Context.console
or by passing a console toTermUI
functions.
2018-07-31
path()
type for parameter values
- Clikt now targets JVM 8 bytecode
- Responses to
TermUi.confirm()
are now case-insensitive
2018-06-23
defaultLazy
extension for options and arguments
main
now prints messages to stderr instead of stdout
- Parameter help messages are now wrapped more consistently
2018-05-07
- Default parameter to
option().default()
- Treat tokens with unknown prefixes as arguments (this makes it easier
to pass in file paths without using
--
).
2018-04-15
List<String>
overloads toCliktCommand.parse
andmain
err
parameter toTermUi.echo
error
property toAbort