1
0
mirror of https://github.com/jht5945/buildj.git synced 2025-12-27 17:20:06 +08:00

update verbose

This commit is contained in:
2019-08-09 00:21:19 +08:00
parent 9b504d255e
commit 9bcff398a4
6 changed files with 31 additions and 8 deletions

1
Cargo.lock generated
View File

@@ -80,6 +80,7 @@ version = "0.1.2"
dependencies = [
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"json 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"rust_util 0.1.0 (git+https://github.com/jht5945/rust_util)",

View File

@@ -11,4 +11,5 @@ reqwest = "0.9.18"
urlencoding = "1.0.0"
dirs = "2.0.1"
rust-crypto = "0.2.36"
lazy_static = "1.3.0"
rust_util = { git = "https://github.com/jht5945/rust_util" }

View File

@@ -3,4 +3,7 @@ fn main() {
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
let date_output = Command::new("date").output().unwrap();
let date = String::from_utf8(date_output.stdout).unwrap();
println!("cargo:rustc-env=BUILD_DATE={}", date);
}

View File

@@ -11,11 +11,12 @@ use rust_util::{
XResult,
};
use super::misc::*;
use super::misc::{
VERBOSE,
};
pub fn download_url(url: &str, dest: &mut File) -> XResult<()> {
let verbose = is_verbose();
if verbose {
if *VERBOSE {
print_message(MessageType::DEBUG, &format!("Download URL: {}", url));
}
let mut response = reqwest::get(url)?;
@@ -23,7 +24,7 @@ pub fn download_url(url: &str, dest: &mut File) -> XResult<()> {
None => -1,
Some(len_value) => len_value.to_str().unwrap().parse::<i64>().unwrap(),
};
if verbose {
if *VERBOSE {
print_message(MessageType::DEBUG, &format!("Content-Length: {}", header_content_length));
}
copy_io(&mut response, dest, header_content_length)?;
@@ -31,7 +32,7 @@ pub fn download_url(url: &str, dest: &mut File) -> XResult<()> {
}
pub fn get_url(url: &str) -> XResult<String> {
if is_verbose() {
if *VERBOSE {
print_message(MessageType::DEBUG, &format!("Get URL: {}", url));
}
Ok(reqwest::get(url)?.text()?)

View File

@@ -5,6 +5,8 @@ extern crate dirs;
extern crate crypto;
extern crate urlencoding;
extern crate rust_util;
#[macro_use]
extern crate lazy_static;
pub mod jdk;
pub mod local_util;
@@ -33,6 +35,7 @@ use misc::*;
const BUILDJ: &str = "buildj";
const BUDERJ_VER: &str = env!("CARGO_PKG_VERSION");
const GIT_HASH: &str = env!("GIT_HASH");
const BUILD_DATE: &str = env!("BUILD_DATE");
fn do_with_buildin_arg_java(first_arg: &str, args: &Vec<String>) {
@@ -137,6 +140,11 @@ fn do_with_buildin_args(args: &Vec<String>) {
fn main() {
print_message(MessageType::INFO, &format!("{} - version {} - {}", BUILDJ, BUDERJ_VER, &GIT_HASH[0..7]));
if *VERBOSE {
print_message(MessageType::DEBUG, &format!("Full GIT_HASH: {}", GIT_HASH));
print_message(MessageType::DEBUG, &format!("Binary build date: {}", BUILD_DATE));
}
let args = local_util::get_args_as_vec();
print_message(MessageType::INFO, &format!("Arguments: {:?}", args));

View File

@@ -1,15 +1,24 @@
use std::env;
lazy_static! {
pub static ref VERBOSE: bool = is_verbose();
}
pub fn print_usage() {
print!(r#"
buildj ::: - print this message
buildj :::help - print this message
buildj :::create --java<version> --maven<version> - create java-version, maven-version project
e.g. buildj :::create --java1.8 --maven3.5.2
buildj :::create --java<version> --gradle<version> - create java-version, gradle-version project
buildj :::java<version> [-version] - run java with assigned version, e.g. buildj :::java1.8 -version
buildj :::maven<version> [--java<version>] - run maven with assigned version and java version, e.g. buildj :::maven3.5.2 --java1.8 ARGS
buildj :::gradle<version> [--java<version>] - run gradle with assigned version and java version, e.g. buildj :::gradle3.5.1 --java1.8 ARGS
e.g. buildj :::create --java1.8 --gradle3.5.1
buildj :::java<version> [-version] - run java with assigned version
e.g. buildj :::java1.8 -version
buildj :::maven<version> [--java<version>] - run maven with assigned version and java version
e.g. buildj :::maven3.5.2 --java1.8 ARGS
buildj :::gradle<version> [--java<version>] - run gradle with assigned version and java version
e.g. buildj :::gradle3.5.1 --java1.8 ARGS
buildj - run build, run assigned version builder tool
"#);
}