Expand description
Common functionality for Workhelix Rust CLI tools.
This library provides shared functionality for CLI tools including:
- Shell completion generation
- Self-update mechanism with GitHub releases
- Health check framework
- License display
- Terminal output utilities
§Example Usage
use workhelix_cli_common::{
RepoInfo, DoctorChecks, DoctorCheck,
completions, doctor, license, update,
};
use clap::Parser;
#[derive(Parser)]
struct Cli {
// your CLI definition
}
struct MyTool;
impl DoctorChecks for MyTool {
fn repo_info() -> RepoInfo {
RepoInfo::new("myorg", "mytool", "mytool-v")
}
fn current_version() -> &'static str {
env!("CARGO_PKG_VERSION")
}
fn tool_checks(&self) -> Vec<DoctorCheck> {
vec![
DoctorCheck::file_exists("~/.config/mytool/config.toml"),
]
}
}
// Generate completions
completions::generate_completions::<Cli>(clap_complete::Shell::Bash);
// Run health check
let tool = MyTool;
let exit_code = doctor::run_doctor(&tool);
// Run self-update
let exit_code = update::run_update(
&MyTool::repo_info(),
MyTool::current_version(),
None,
false,
None,
);Re-exports§
pub use doctor::DoctorChecks;pub use license::LicenseType;pub use types::DoctorCheck;pub use types::RepoInfo;pub use completions::generate_completions;pub use doctor::check_for_updates;pub use doctor::run_doctor;pub use license::display_license;pub use update::get_latest_version;pub use update::run_update;