mirror of
https://github.com/jht5945/prettyjson.git
synced 2025-12-27 09:10:04 +08:00
use rust_util
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -138,6 +138,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"argparse 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"json 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"json 0.11.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rust_util 0.1.0 (git+https://github.com/jht5945/rust_util)",
|
||||||
"term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -207,6 +208,14 @@ dependencies = [
|
|||||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust_util"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/jht5945/rust_util#8dd2f042609d8b3235f537cada75d891cf0d7b0c"
|
||||||
|
dependencies = [
|
||||||
|
"term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.15"
|
version = "0.1.15"
|
||||||
@@ -300,6 +309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
||||||
"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828"
|
"checksum redox_users 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe5204c3a17e97dde73f285d49be585df59ed84b50a872baf416e73b62c3828"
|
||||||
|
"checksum rust_util 0.1.0 (git+https://github.com/jht5945/rust_util)" = "<none>"
|
||||||
"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
|
"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af"
|
||||||
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||||
"checksum syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)" = "bc945221ccf4a7e8c31222b9d1fc77aefdd6638eb901a6ce457a3dc29d4c31e8"
|
"checksum syn 0.15.40 (registry+https://github.com/rust-lang/crates.io-index)" = "bc945221ccf4a7e8c31222b9d1fc77aefdd6638eb901a6ce457a3dc29d4c31e8"
|
||||||
|
|||||||
@@ -8,3 +8,4 @@ edition = "2018"
|
|||||||
argparse = "0.2.2"
|
argparse = "0.2.2"
|
||||||
json = "0.11.14"
|
json = "0.11.14"
|
||||||
term = "0.5.2"
|
term = "0.5.2"
|
||||||
|
rust_util = { git = "https://github.com/jht5945/rust_util" }
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
extern crate argparse;
|
extern crate argparse;
|
||||||
extern crate term;
|
extern crate term;
|
||||||
extern crate json;
|
extern crate json;
|
||||||
|
extern crate rust_util;
|
||||||
mod util;
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
@@ -12,7 +11,7 @@ use std::{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
use argparse::{ArgumentParser, StoreTrue, Store};
|
use argparse::{ArgumentParser, StoreTrue, Store};
|
||||||
use util::*;
|
use rust_util::*;
|
||||||
|
|
||||||
const VERSION: &str = "0.1";
|
const VERSION: &str = "0.1";
|
||||||
|
|
||||||
|
|||||||
24
src/util.rs
24
src/util.rs
@@ -1,24 +0,0 @@
|
|||||||
pub type XResult<T> = Result<T, Box<dyn std::error::Error>>;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum MessageType { INFO, OK, WARN, ERROR, }
|
|
||||||
|
|
||||||
pub fn print_message_ex(color: Option<term::color::Color>, h: &str, message: &str) {
|
|
||||||
let mut t = term::stdout().unwrap();
|
|
||||||
match color {
|
|
||||||
Some(c) => t.fg(c).unwrap(),
|
|
||||||
None => (),
|
|
||||||
}
|
|
||||||
write!(t, "{}", h).unwrap();
|
|
||||||
t.reset().unwrap();
|
|
||||||
println!(" {}", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn print_message(mt: MessageType, message: &str) {
|
|
||||||
match mt {
|
|
||||||
MessageType::OK => print_message_ex(Some(term::color::GREEN), "[OK ]", message),
|
|
||||||
MessageType::WARN => print_message_ex(Some(term::color::YELLOW), "[WARN ]", message),
|
|
||||||
MessageType::ERROR => print_message_ex(Some(term::color::RED), "[ERROR]", message),
|
|
||||||
MessageType::INFO => print_message_ex(None, "[INFO]", message),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user