clish
The most elegant CLI framework for Rust.
clish (/klɪʃ/ "KEL-ish")
use *;
Inspired by Typer
Quick Start
[]
= "0.1.0-beta.5"
use *;
# Hello, Alice!
Usage
Argument Types
| Type | CLI Form |
|---|---|
Pos<T> |
<arg> required positional |
Pos<Option<T>> |
[arg] optional positional |
Pos<Vec<T>> |
<arg>... variadic (zero or more) |
Named<T> |
--name <val> required option |
Named<Option<T>> |
[--name <val>] optional option |
Named<Vec<T>> |
--name <val> --name <val> repeatable |
bool |
--flag presence flag |
Named options support --name=value, --name value, and -n value forms.
Flags support bundling: -abc is equivalent to -a -b -c.
Command Options
Parameter Options
| Key | Type | Description |
|---|---|---|
help |
string | Short description |
details |
string | Long description (shown only in --help) |
name |
string | Override the CLI flag name |
short |
char | Single-character alias (-d) |
placeholder |
string | Custom help token |
hide |
bool | Omit from help listings |
default |
string | Default value |
env |
string | Environment variable fallback |
choices |
array | Allowed values |
conflicts_with |
array | Mutual exclusion |
requires |
array | Prerequisites |
value_hint |
string | Shell completion hint (reserved) |
Resolution order: CLI argument > $ENV_VAR > default > error.
Oneshot Mode
Pass a command function to app!() for single-command CLIs without subcommand dispatch:
use *;
Oneshot mode enforces that the command has no custom name, aliases, hidden, or deprecated attributes, and that no other commands are registered.
Compact Usage
Commands with many options can clutter the usage line. By default, clish collapses
the usage to [OPTIONS] when a command has more than 5 named options and flags:
# Default: 6+ options -> compact
Usage: myapp deploy <HOST> [OPTIONS]
# 5 or fewer -> full listing
Usage: myapp deploy <HOST> [-p <PORT>] [-l <LEVEL>] [-v]
Configure the threshold or disable it entirely:
app!
.compact_usage_limit // collapse at 10+ options
.compact_usage // always collapse (shorthand for Some(0))
.compact_usage // never collapse (shorthand for None)
.run;
The full Arguments and Options sections are always shown regardless.
Styling
use *;
use ;
app!
.styles
.run;
Or use anstyle::Style values directly:
use ;
app!
.styles
.run;
Error Handling
Errors are printed to stderr with structured formatting:
error: unknown command 'deplyo'
|
1 | myapp deplyo
| ^^^^^^
|
= hint: run 'myapp --help' for available commands
Command functions can return Result<(), String> for custom error handling.
Documentation
Full docs: https://razkar.codeberg.page/clish API documentation: https://docs.rs/clish
License
MIT or Apache-2.0
Cheers, RazkarStudio.
Copyright (c) 2026 RazkarStudio. All rights reserved.