1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use clap::{Parser, Subcommand, ValueEnum};
use clap_complete::Shell;
#[derive(Parser)]
#[command(
name = "makectl",
version,
about = "Generate and manage targets in your Makefiles"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
/// Path to Makefile
#[arg(short, long, global = true, default_value = "Makefile")]
pub file: String,
/// Interactive mode (prompts for selections)
#[arg(short, long, global = true)]
pub interactive: bool,
}
#[derive(Subcommand)]
pub enum Commands {
/// Create a new Makefile from scratch
Init {
/// Language template to use
#[arg(short, long)]
lang: Option<Language>,
/// Force overwrite if Makefile exists
#[arg(long)]
force: bool,
},
/// Add template targets to existing Makefile
Add {
/// Templates to add (e.g., python/test, rust/build)
templates: Vec<String>,
},
/// Remove a managed target from Makefile
Remove {
/// Target names to remove
targets: Vec<String>,
},
/// List available templates (default) or Makefile targets
List {
/// Show targets in the Makefile instead of available templates
#[arg(long)]
targets: bool,
/// Filter by language
#[arg(short, long)]
lang: Option<Language>,
},
/// Lint Makefile for common issues
Lint,
/// Format Makefile
Fmt {
/// Check only, don't modify
#[arg(long)]
check: bool,
},
/// Validate Makefile syntax
Validate,
/// Show Makefile best practice tips
Tips,
/// Generate shell completions
Completions {
/// Shell to generate for
#[arg(value_enum)]
shell: Shell,
},
}
#[derive(Clone, ValueEnum, Debug)]
pub enum Language {
Generic,
Python,
Rust,
Go,
Node,
}
impl Language {
pub fn as_str(&self) -> &str {
match self {
Language::Generic => "generic",
Language::Python => "python",
Language::Rust => "rust",
Language::Go => "go",
Language::Node => "node",
}
}
}