-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::process::Command; | ||
|
||
use clap::{ | ||
Parser, | ||
ArgAction | ||
}; | ||
|
||
use crate::utils::find_gradle; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct Build { | ||
/// Should build in release mode | ||
#[clap(short, long, default_value="false", action = ArgAction::SetTrue)] | ||
release: bool | ||
} | ||
|
||
pub fn handle(args: Build) { | ||
let gradle_path = find_gradle().expect("ERROR: Gradle not found on system"); | ||
|
||
// Decide gradle subcommand to use | ||
let cmd = match args.release { | ||
true => "assembleRelease", | ||
false => "assembleDebug" | ||
}; | ||
|
||
// Invoke gradle as child process | ||
println!("Invoking Gradle: {}", gradle_path); | ||
let status = Command::new(gradle_path) | ||
.arg(cmd) | ||
.status() | ||
.unwrap(); | ||
|
||
match status.success() { | ||
true => println!("Success!"), | ||
false => println!("Failed while executing Gradle.") | ||
} | ||
} |
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 +1,2 @@ | ||
pub mod create; | ||
pub mod build; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
use which::which; | ||
|
||
pub fn prompt_for_input(prompt: &str) -> String { | ||
dialoguer::Input::<String>::with_theme(&dialoguer::theme::ColorfulTheme::default()) | ||
.with_prompt(prompt) | ||
.interact_text() | ||
.unwrap() | ||
} | ||
|
||
pub fn find_gradle() -> Option<String> { | ||
if std::path::Path::new("./gradlew").exists() { | ||
return Some("./gradlew".to_owned()); | ||
} | ||
|
||
if which("gradle").is_ok() { | ||
return Some("gradle".to_owned()); | ||
} | ||
|
||
None | ||
} |