Expand description
§cliclack-file-autocompletion
File path autocompletion for cliclack prompts.
§Usage
Add to Cargo.toml:
[dependencies]
cliclack = "0.5"
cliclack-file-autocompletion = "0.1"§Simple
use cliclack_file_autocompletion::FileAutocompleteExt;
let path: String = cliclack::input("Pick a file")
.file_autocomplete()
.interact()?;§With settings
use cliclack_file_autocompletion::{FileAutocompleteExt, FileSettings};
let path: String = cliclack::input("Pick a file or folder")
.file_autocomplete_with(FileSettings {
allow_folders: true,
show_hidden: true,
..Default::default()
})
.interact()?;§Extension filter
use cliclack_file_autocompletion::{FileSuggest, FileSettings};
let path: String = cliclack::input("Pick a .rs file")
.autocomplete(FileSuggest::new(".").with_settings(FileSettings {
extensions: Some(vec!["rs".into()]),
..Default::default()
}))
.interact()?;§Custom root
use cliclack_file_autocompletion::FileSuggest;
let path: String = cliclack::input("Pick a file")
.autocomplete(FileSuggest::new("/home"))
.interact()?;§Behaviour
~and$ENV_VARSin typed paths are expanded automatically.- Relative paths resolve against the configured root (default:
.). - Absolute paths bypass the root.
- Folders appear in suggestions only once the user starts typing a fragment — listing a directory shows files only.
allow_folders/allow_filesare enforced at submission via validation, not by hiding entries during navigation.- Hidden files (
.dotfiles) are hidden by default; enable withshow_hidden: true.
§Running the example
cargo run --example basicStructs§
- File
Settings - Controls which filesystem entries are shown and accepted.
- File
Suggest - A
cliclack::Suggestimplementation that reads the filesystem.
Traits§
- File
Autocomplete Ext - Extension methods on
cliclack::Inputfor file path autocompletion.