Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Feb 7, 2024
1 parent 999ea76 commit ce12892
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,13 @@ line:
You might want a flag option that counts the number of times it occurs on the command line. You can
use [`counted`][counted] for this.

You can specify a `limit` for the number of times the [`counted`][counted] option can be given,
and either `clamp` the value or show an error if the limit is exceeded.

=== "Example"
```kotlin
class Log : CliktCommand() {
val verbosity by option("-v").counted()
val verbosity by option("-v").counted(limit=3, clamp=true)
override fun run() {
echo("Verbosity level: $verbosity")
}
Expand All @@ -461,6 +464,7 @@ use [`counted`][counted] for this.
Verbosity level: 3
```


## Feature Switch Flags

Another way to use flags is to assign a value to each option name. You can do this with
Expand Down

0 comments on commit ce12892

Please sign in to comment.