138 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

//! {{TOOL_NAME}} CLI Tool
//!
//! Command-line interface for {{TOOL_NAME}}.
use clap::{Parser, Subcommand};
use {{TOOL_NAME}}_core::*;
use tools_shared::find_config_path;
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "{{tool_name_kebab}}")]
#[command(about = "{{TOOL_NAME}} - {{SHORT_DESCRIPTION}}")]
#[command(long_about = r#"{{TOOL_NAME}}
CONFIGURATION SEARCH:
Looks for config in order (uses first found):
1. .project/{{tool_name_kebab}}.toml - If using Tools
2. .vapora/{{tool_name_kebab}}.toml - If VAPORA project
3. .coder/{{tool_name_kebab}}.toml - If doc tracking
4. ./{{tool_name_kebab}}.toml - Current directory
The tool automatically uses the first existing location.
Example: If .project/ doesn't exist but .vapora/ does,
it will use .vapora/{{tool_name_kebab}}.toml automatically.
DIRECTORIES:
.project/ - Tools installation
.vapora/ - VAPORA platform configuration
.coder/ - Project documentation & agent interaction
.claude/ - Claude Code integration
"#)]
#[command(version = env!("CARGO_PKG_VERSION"))]
struct Cli {
/// Configuration file path (uses search order if not specified)
#[arg(short, long)]
config: Option<PathBuf>,
/// Verbose logging output
#[arg(short, long, global = true)]
verbose: bool,
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// List items
List {
/// Filter pattern
#[arg(short, long)]
filter: Option<String>,
/// Limit results
#[arg(short, long, default_value = "20")]
limit: usize,
},
/// Show summary
Summary {
/// Group by field
#[arg(short, long)]
group_by: Option<String>,
},
/// Create new item
Create {
/// Item name
name: String,
/// Item description
#[arg(short, long)]
description: Option<String>,
},
/// Show version
Version,
}
#[tokio::main]
async fn main() -> Result<()> {
let cli = Cli::parse();
// Initialize logging
let log_level = if cli.verbose { "debug" } else { "info" };
tracing_subscriber::fmt()
.with_env_filter(log_level)
.init();
// Resolve configuration path using smart search
let config_path = if let Some(explicit_path) = &cli.config {
explicit_path.clone()
} else {
// Use config_finder to search for config in standard locations
find_config_path("{{tool_name_kebab}}.toml")
.unwrap_or_else(|| PathBuf::from(".project/{{tool_name_kebab}}.toml"))
};
tracing::info!("Using config: {}", config_path.display());
match cli.command {
Commands::List { filter, limit } => {
println!("📋 {{TOOL_NAME}} Items");
if let Some(f) = &filter {
println!(" Filter: {}", f);
}
println!(" Limit: {}", limit);
println!();
println!(" (Implementation coming soon)");
}
Commands::Summary { group_by } => {
println!("📊 {{TOOL_NAME}} Summary");
if let Some(g) = &group_by {
println!(" Group by: {}", g);
}
println!();
println!(" (Implementation coming soon)");
}
Commands::Create { name, description } => {
println!("✨ Creating: {}", name);
if let Some(desc) = &description {
println!(" Description: {}", desc);
}
println!();
println!(" (Implementation coming soon)");
}
Commands::Version => {
println!("{{tool_name_kebab}} v{}", env!("CARGO_PKG_VERSION"));
}
}
Ok(())
}