1use anyhow::Result;
2use structopt::StructOpt;
3
4mod build;
5mod compiler;
6mod disasm;
7mod export;
8mod gc;
9mod logger;
10mod manifest;
11#[cfg(feature = "play")]
12mod play;
13mod render;
14mod watcher;
15mod workspace;
16
17#[cfg(feature = "remote")]
18mod serve;
19
20#[derive(Debug, StructOpt)]
21enum Arguments {
22 Build(build::Build),
23 #[cfg(feature = "play")]
24 #[structopt(alias = "p")]
25 Play(play::Play),
26 #[cfg(feature = "remote")]
27 Serve(serve::Serve),
28 Disasm(disasm::Disasm),
29 Export(export::Export),
30 Render(render::Render),
31 Gc(gc::Gc),
32 #[structopt(alias = "ws")]
33 Workspace(workspace::Workspace),
34}
35
36static mut IS_ALT_SCREEN: bool = false;
37
38pub fn is_alt_screen() -> bool {
39 unsafe { IS_ALT_SCREEN }
40}
41
42fn init_logger(args: &Arguments) {
43 #[cfg(feature = "play")]
44 {
45 if matches!(args, Arguments::Play(_)) {
46 logger::init_tui();
47 return;
48 }
49 }
50
51 logger::init();
52 let _ = args;
53}
54
55pub fn main() {
56 let args = Arguments::from_args();
57
58 init_logger(&args);
59
60 let res = match args {
61 Arguments::Build(args) => args.run(),
62 #[cfg(feature = "play")]
63 Arguments::Play(args) => args.run(),
64 Arguments::Disasm(args) => args.run(),
65 #[cfg(feature = "remote")]
66 Arguments::Serve(args) => args.run(),
67 Arguments::Export(args) => args.run(),
68 Arguments::Render(args) => args.run(),
69 Arguments::Gc(args) => args.run(),
70 Arguments::Workspace(args) => args.run(),
71 };
72
73 if let Err(err) = res {
74 logger::error!("{}", err);
75 }
76}