Skip to content

Commit 0000063

Browse files
committed
feat: started new cli
1 parent fc8a6b4 commit 0000063

6 files changed

Lines changed: 160 additions & 107 deletions

File tree

Cargo.lock

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/compiler_main/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ lexer = { path = "../lexer" }
1111
llvm_ir_bridge = { path = "../llvm_ir_bridge", optional = true, default-features = false }
1212
diagnostics = { path = "../diagnostics" }
1313
compiler_utils = { path = "../compiler_utils" }
14+
clap = { version = "4.0", features = ["derive"] }
1415

1516
[features]
1617
llvm = ["llvm_ir_bridge"]

compiler/compiler_main/src/cli.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use clap::{Parser, Subcommand, ValueEnum};
2+
3+
#[derive(Parser)]
4+
pub struct Cli {
5+
#[command(subcommand)]
6+
pub command: CLICommand,
7+
}
8+
9+
#[derive(Clone, Copy, PartialEq, Eq, ValueEnum, Debug)]
10+
pub enum Platform {
11+
AstoIR,
12+
LLVM,
13+
}
14+
15+
#[derive(Subcommand)]
16+
pub enum CLICommand {
17+
#[command(visible_alias = "b")]
18+
Build {
19+
#[arg(short = 'o')]
20+
out: String,
21+
22+
#[arg(long, value_enum, default_value = "llvm")]
23+
platform: Platform,
24+
25+
#[arg(required = true)]
26+
input: Vec<String>,
27+
},
28+
}

compiler/compiler_main/src/cmds/astoir.rs

Lines changed: 0 additions & 86 deletions
This file was deleted.

compiler/compiler_main/src/cmds/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

compiler/compiler_main/src/main.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
use std::env;
1+
use clap::Parser;
22

3-
use crate::cmds::astoir::parse_astoir_command;
3+
use crate::cli::{CLICommand, Cli};
44

5-
pub mod cmds;
5+
pub mod cli;
66

77
fn main() {
8-
let arguments: Vec<String> = env::args().collect();
9-
10-
if arguments.len() <= 1 {
11-
println!("Usage: quickfall comp|astoir");
12-
return;
13-
}
14-
15-
match &arguments[1] as &str {
16-
"astoir" => {
17-
parse_astoir_command(arguments);
18-
}
19-
20-
_ => {
21-
println!("Invalid subcommand!");
22-
return;
23-
}
24-
}
8+
let cli = Cli::parse();
259
}

0 commit comments

Comments
 (0)