Skip to main content

Crate tftio_cli_common

Crate tftio_cli_common 

Source
Expand description

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

Re-exports§

pub use doctor::DoctorChecks;
pub use license::LicenseType;
pub use types::DoctorCheck;
pub use types::RepoInfo;
pub use agent::AGENT_TOKEN_ENV;
pub use agent::AGENT_TOKEN_EXPECTED_ENV;
pub use agent::AgentCapability;
pub use agent::AgentDispatch;
pub use agent::AgentModeContext;
pub use agent::AgentSkillError;
pub use agent::AgentSurfaceSpec;
pub use agent::CommandSelector;
pub use agent::FlagSelector;
pub use agent::ProcessEnv;
pub use agent::apply_agent_surface;
pub use agent::parse_with_agent_surface_from;
pub use agent::render_agent_help;
pub use agent::render_agent_skill;
pub use agent::AgentSubcommand;
pub use agent::DescribeFormat;
pub use agent::EmitScope;
pub use agent::EmitTarget;
pub use agent::ListFormat;
pub use agent_skill::EmitDirError;
pub use agent_skill::render_describe;
pub use agent_skill::render_list;
pub use agent_skill::render_skill_md;
pub use agent_skill::resolve_emit_dir;
pub use agent_skill::run_agent_subcommand;
pub use agent_skill::skill_name;
pub use app::ContractError;
pub use app::ToolContract;
pub use app::ToolSpec;
pub use app::workspace_tool;
pub use binary::run_cli_from;
pub use binary::run_cli_no_doctor_from;
pub use command::NoDoctor;
pub use command::StandardCommand;
pub use command::StandardCommandMap;
pub use command::map_standard_command;
pub use command::maybe_run_standard_command;
pub use command::maybe_run_standard_command_no_doctor;
pub use command::parse_command_ref_with_agent_surface_from;
pub use command::parse_command_with_agent_surface_from;
pub use command::run_standard_command_no_doctor;
pub use completions::CompletionOutput;
pub use completions::generate_completions;
pub use completions::generate_completions_from_command;
pub use completions::render_completion;
pub use completions::render_completion_from_command;
pub use completions::render_completion_instructions;
pub use completions::write_completion;
pub use doctor::DoctorReport;
pub use doctor::print_doctor_report_json;
pub use doctor::print_doctor_report_text;
pub use doctor::run_doctor;
pub use doctor::run_doctor_with_output;
pub use error::fatal_error;
pub use error::print_error;
pub use json::JsonOutput;
pub use json::err_response;
pub use json::ok_response;
pub use json::render_response;
pub use json::render_response_parts;
pub use json::render_response_with;
pub use license::display_license;
pub use meta::MetaCommand;
pub use progress::make_spinner;
pub use runner::FatalCliError;
pub use runner::parse_and_exit;
pub use runner::parse_and_run;
pub use runner::run_with_display_error_handler;
pub use runner::run_with_fatal_handler;

Modules§

agent
Shared agent-mode capability declarations and filtering helpers.
agent_skill
Ungated agent-skill artifact generation.
app
Shared CLI application metadata.
binary
Shared binary entrypoint helpers for workspace CLI tools.
command
Shared standard CLI commands.
completions
Shell completion generation module.
doctor
Health check and diagnostics module.
error
Shared error presentation.
json
Shared JSON response helpers.
license
License display module.
meta
Canonical metadata command surface shared across workspace binaries.
output
Output utilities for consistent terminal formatting.
progress
Shared progress indicator helpers.
runner
Shared CLI runner helpers.
types
Shared types for Workhelix CLI tools.

Macros§

impl_standard_command_map
Implement StandardCommandMap for a crate-local metadata enum that uses the workspace-standard variant names.