-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move cli command related stuff to cli module.
- Loading branch information
Showing
3 changed files
with
33 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
use clap::Command; | ||
use std::process::ExitCode; | ||
use crate::cli::logging::dump_failure; | ||
|
||
pub mod run; | ||
pub mod check; | ||
pub mod transpile; | ||
pub mod logging; | ||
pub mod logging; | ||
|
||
pub fn make_command() -> Command { | ||
Command::new("monoteny") | ||
.about("A cli implementation for the monoteny language.") | ||
.subcommand_required(true) | ||
.arg_required_else_help(true) | ||
.allow_external_subcommands(true) | ||
.subcommand(run::make_command()) | ||
.subcommand(check::make_command()) | ||
.subcommand(transpile::make_command()) | ||
} | ||
|
||
pub fn run_command() -> ExitCode { | ||
let matches = make_command().get_matches(); | ||
|
||
let result = match matches.subcommand() { | ||
Some(("run", sub_matches)) => run::run(sub_matches), | ||
Some(("check", sub_matches)) => check::run(sub_matches), | ||
Some(("transpile", sub_matches)) => transpile::run(sub_matches), | ||
_ => panic!("Unsupported action."), | ||
}; | ||
|
||
result.unwrap_or_else(|e| dump_failure(e)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters