Opinionated Android 15+ Linux Terminal Setup
android
linux
command-line-tools
1use anyhow::Error;
2use clap::{Command, arg};
3use owo_colors::OwoColorize;
4
5use crate::{
6 cmd::{init::init, setup::setup},
7 consts::CONFIG_FILE,
8};
9
10pub mod apply;
11pub mod cmd;
12pub mod command;
13pub mod config;
14pub mod consts;
15pub mod diff;
16pub mod git;
17
18fn cli() -> Command {
19 let banner = format!(
20 "{}\nTurn a fresh {} into a fully-configured, beautiful, and modern web development system by running a single command.",
21 r#"
22 ______ _________ ______________
23 _________ /_ _______ ________ __ ______ /_______________(_)_____ /
24 _ __ \_ __ \ __ __ `__ \_ / / / _ __ /__ ___/ __ \_ /_ __ /
25 / /_/ / / / / _ / / / / / /_/ / / /_/ / _ / / /_/ / / / /_/ /
26 \____//_/ /_/ /_/ /_/ /_/_\__, / \__,_/ /_/ \____//_/ \__,_/
27 /____/
28
29"#
30 .green(),
31 "Android 15+ Linux Terminal".green()
32 );
33
34 Command::new("oh-my-droid")
35 .version(env!("CARGO_PKG_VERSION"))
36 .author("Tsiry Sandratraina <tsiry.sndr@rocksky.app>")
37 .about(&banner)
38 .subcommand(Command::new("init").about(&format!(
39 "Write the initial configuration file {}.",
40 CONFIG_FILE.green()
41 )))
42 .subcommand(
43 Command::new("setup")
44 .about("Set up the environment with the default configuration.")
45 .arg(arg!(-d --"dry-run" "Simulate the setup process without making any changes."))
46 .arg(arg!(-y --"yes" "Skip confirmation prompts during setup."))
47 .arg(
48 arg!([config] "Path to a custom configuration file or a remote git repository e.g., github:tsirysndr/pkgs")
49 .default_value(CONFIG_FILE),
50 )
51 .alias("apply"),
52 )
53 .arg(arg!(-d --"dry-run" "Simulate the setup process without making any changes."))
54 .arg(arg!(-y --"yes" "Skip confirmation prompts during setup."))
55 .arg(
56 arg!([config] "Path to a custom configuration file or a remote git repository e.g., github:tsirysndr/pkgs")
57 .default_value(CONFIG_FILE),
58 )
59 .after_help("If no subcommand is provided, the 'setup' command will be executed by default.")
60}
61
62fn main() -> Result<(), Error> {
63 let matches = cli().get_matches();
64
65 match matches.subcommand() {
66 Some(("init", _)) => init()?,
67 Some(("setup", args)) => {
68 let yes = args.get_flag("yes");
69 let dry_run = args.get_flag("dry-run");
70 let config = args.get_one::<String>("config").unwrap();
71 setup(dry_run, yes, config)?
72 }
73 _ => {
74 let yes = matches.get_flag("yes");
75 let dry_run = matches.get_flag("dry-run");
76 let config = matches.get_one::<String>("config").unwrap();
77 setup(dry_run, yes, config)?
78 }
79 }
80
81 Ok(())
82}