1#![doc = include_str!("../docs/overview.md")]
2
3use dada_debug::DebugOptions;
4use dada_ir_ast::diagnostic::RenderOptions;
5use dada_util::Fallible;
6use structopt::StructOpt;
7
8mod main_lib;
9
10use dada_compiler::Db;
11
12#[derive(Debug, StructOpt)]
13pub struct Options {
14 #[structopt(flatten)]
15 global_options: GlobalOptions,
16
17 #[structopt(subcommand)]
18 command: Command,
19}
20
21#[derive(Debug, StructOpt)]
22pub struct GlobalOptions {
23 #[structopt(long)]
24 no_color: bool,
25}
26
27impl GlobalOptions {
28 pub(crate) fn test_options() -> Self {
29 Self { no_color: false }
30 }
31
32 pub(crate) fn render_opts(&self) -> RenderOptions {
33 RenderOptions {
34 no_color: self.no_color,
35 }
36 }
37}
38
39#[derive(Debug, StructOpt)]
40pub enum Command {
41 Compile {
42 #[structopt(flatten)]
43 compile_options: CompileOptions,
44 },
45
46 Run {
47 #[structopt(flatten)]
48 run_options: RunOptions,
49 },
50
51 Test {
52 #[structopt(flatten)]
53 test_options: TestOptions,
54 },
55
56 Debug {
57 #[structopt(flatten)]
58 debug_options: DebugOptions,
59
60 #[structopt(flatten)]
61 compile_options: CompileOptions,
62 },
63}
64
65#[derive(Debug, StructOpt)]
66pub struct CompileOptions {
67 input: String,
69}
70
71#[derive(Debug, StructOpt)]
72pub struct RunOptions {
73 #[structopt(flatten)]
74 compile_options: CompileOptions,
75}
76
77#[derive(Debug, StructOpt)]
78pub struct TestOptions {
79 #[structopt(long, short)]
81 verbose: bool,
82
83 #[structopt(long)]
85 porcelain: bool,
86
87 inputs: Vec<String>,
89}
90
91impl Options {
92 pub fn main(self) -> Fallible<()> {
93 main_lib::Main::new(self.global_options).run(self.command)
94 }
95}