tftio-cli-common 3.0.3

Common functionality for tftio Rust CLI tools
Documentation

Common functionality for Workhelix Rust CLI tools.

This library provides shared functionality for CLI tools including:

  • Shell completion generation
  • Health check framework
  • License display
  • Terminal output utilities

Example Usage

use tftio_cli_common::{
    RepoInfo, DoctorChecks, DoctorCheck,
    completions, doctor, license,
};
use clap::Parser;

#[derive(Parser)]
struct Cli {
    // your CLI definition
}

struct MyTool;

impl DoctorChecks for MyTool {
    fn repo_info() -> RepoInfo {
        RepoInfo::new("myorg", "mytool")
    }

    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);