Easy-to-use TUI & CLI to interact with Clash RESTful API.
crates.io
bash
$ cargo install clashctl --vers 0.3.0-alpha.3 --all-features
bash
$ git clone https://github.com/George-Miao/clashctl.git
$ cd clashctl
$ cargo install --features "cli, ui" --path .
Use command without subcommands defaults to open TUI:
```bash $ clashctl
$ clashctl tui ```
Or use a subcommand to use the cli:
```bash $ clashctl proxy list
selector - All
URLTest - Auto-All
ShadowsocksR 19 SomeProxy-1
Vmess 177 SomeProxy-2
Vmess 137 SomeProxy-3
Shadowsocks 143 SomeProxy-4
```
You will need nightly rust environment (Cargo & rustc) to compile and install
```bash $ clashctl -h clashctl
George Miao gm@miao.dev
CLI used to interact with Clash RESTful API
USAGE:
clashctl [OPTIONS]
OPTIONS:
-c, --config
SUBCOMMANDS: completion Generate auto-completion scripts help Print this message or the help of the given subcommand(s) proxy Interacting with proxies server Interacting with servers ```
```toml
[dependencies] clashctl = "*" ```
Then in your project:
```rust use clashctl::Clash;
fn main() { let clash = Clash::builder("http://example.com:9090").unwrap().build(); println!("Clash version is {:?}", clash.get_version().unwrap()) } ```
clashctl
comes with a justfile
to speed up your development.
Especially the command just dev
, managed to reproduce the hot reload function in front-end development, with cargo-watch
.
Just
commandsjust dev
[ alias: d
]Hot reload development, auto reload on cargo-check
approved changes, with all features enabled
just run {{ Args }}
[ alias: r
]Run with feature cli & ui
just ui
Run UI only
just cli
Run CLI only
just build
[ alias: b
]Build in release mode with feature cli & ui
just add
Add an optional dependency, requires cargo-edit
bash
$ tree src -L 2
src
├── api.rs # Clash API, with struct `Clash`, export by default
├── bin # Binary dir
│  ├── cli.rs # Cli only
│  ├── cli_ui.rs # Both cli and ui
│  └── ui.rs # Ui only
├── cli # Feature `cli`, depends on clap
│  └── ...
├── error.rs # Error
├── interactive # Feature `interactive`, shared code of `cli` and `ui`
│  └── ...
├── lib.rs # Lib entrance
├── model # Models, export by default
│  └── ...
├── test # Test codes
│  └── ...
└── ui # Feature `ui`
  └── ...