1mod handlers;
2mod types;
3mod utils;
4
5use clap::CommandFactory;
6use types::*;
7#[allow(unused_imports)]
8use handlers::{
9 general::*, aliases::*, create_project::*,
10};
11
12pub fn cli_run() -> Result<(), Box<dyn std::error::Error>> {
13 let args = Cli::parse();
14 let mut path: String;
15 if cfg!(windows) {
16 path = format!("C:\\{}", match args.command {
17 Some(Commands::General(ref cmd)) => cmd.path.clone(),
18 _ => "" .to_owned()
19 });
20 } else {
21 path = format!("{}", match args.command {
22 Some(Commands::General(ref cmd)) => cmd.path.clone(),
23 _ => "" .to_owned()
24 });
25 }
26
27 match args.command {
28 Some(Commands::General(cmd)) => {
29 if cmd.current_user {
30 path = format!("{}", change_dir_current::change_to_current());
31 }
32 if cmd.alias {
33 path = see_alias::see_alias(cmd.path.clone()).expect("This alias does not exists");
34 }
35 if cmd.ls {
36 ls::ls(path.clone());
37 }
38 if cmd.vsc {
39 vsc::open_editor("vsc", path.clone());
40 }
41 },
42 Some(Commands::Aliases(cmd)) => {
43 aliases::aliases(cmd.path, cmd.alias)?;
44 },
45 Some(Commands::CreateProject(cmd)) => {
46 create_project::create_project(
47 cmd.lang,
48 cmd.name,
49 cmd.alias,
50 )?;
51 },
52 None => { Cli::command().print_help().unwrap(); std::process::exit(1); }
53 }
54
55 Ok(())
56}