Skip to content

Commit 9e324d5

Browse files
committed
✨ Automatic Lang detection for rust & node
Running lightmon with no args will work for node projects and rust projects. The cli will look for package.json for a node project and Cargo.toml for a rust project and run the exec commands automatically.
1 parent 67c8b89 commit 9e324d5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/cli.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use clap::{App, ArgMatches};
22
use env_logger::Builder;
33
use log::LevelFilter;
4+
use std::path::Path;
45

56
#[derive(Debug)]
67
pub enum SupportedLanguage {
@@ -44,7 +45,18 @@ impl Cli {
4445
("shell", Some(sub_matcher)) => Some(Self::build_shell_config(sub_matcher)),
4546
_ => {
4647
//automatic lang detection
47-
None
48+
// if Path::new("lightmon.toml").exists(){
49+
// //TODO
50+
// } else if Path::new("nodemon.json").exists() {
51+
//TODO
52+
// }
53+
if Path::new("package.json").exists() {
54+
Some(Self::build_node_config())
55+
} else if Path::new("Cargo.toml").exists() {
56+
Some(Self::build_rust_config())
57+
} else {
58+
None
59+
}
4860
}
4961
};
5062

@@ -74,7 +86,6 @@ impl Cli {
7486
}
7587
pub fn build_shell_config(sub_matcher: &ArgMatches) -> Self {
7688
let mut watch_patterns: Vec<String> = Vec::new();
77-
let project_language: SupportedLanguage;
7889
let mut exec_commands: Vec<String> = Vec::new();
7990
debug!("Configuring for shell mode...");
8091
debug!("Script Path = {:?}", sub_matcher.value_of("script"));

0 commit comments

Comments
 (0)