wini_cli/
cli.rs

1use {
2    crate::just::{args_from_file::arguments_from_justfile_path, search_justfile::search},
3    anstyle::AnsiColor,
4    clap::{crate_version, Command},
5};
6
7pub fn build() -> clap::ArgMatches {
8    let mut command = base_command();
9
10    if let Some(justfile_path) = search() {
11        let justfile = arguments_from_justfile_path(&justfile_path).unwrap();
12        command = command.subcommands(justfile.recipes)
13    } else {
14        command = command.after_help("No justfile found.");
15    }
16
17    command.get_matches()
18}
19
20fn base_command() -> Command {
21    Command::new("wini")
22        .version(crate_version!())
23        .styles(get_styles())
24        .about("Handle your wini project!")
25        .arg_required_else_help(true)
26        .subcommand(
27            Command::new("init").about("Initialize a new wini project"),
28            // .arg(arg!(-u --url "Remote repo URL").action(ArgAction::SetTrue))
29            // .arg(arg!(-b --branch "Remote repo URL on branch").action(ArgAction::SetTrue)),
30        )
31}
32
33pub fn get_styles() -> clap::builder::Styles {
34    clap::builder::Styles::styled()
35        .placeholder(AnsiColor::White.on_default().italic().underline())
36        .usage(AnsiColor::Blue.on_default())
37        .header(AnsiColor::Blue.on_default().bold())
38        .literal(AnsiColor::Cyan.on_default())
39        .invalid(AnsiColor::Red.on_default().bold())
40        .valid(AnsiColor::Green.on_default().bold())
41}