Avoid printing version to not TTY targets and after aqua command (#89)

This commit is contained in:
Mike Voronov 2021-05-26 17:48:16 +03:00 committed by GitHub
parent aa1da858ad
commit b2827a73ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 20 deletions

37
Cargo.lock generated
View File

@ -218,9 +218,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.67" version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -640,9 +640,9 @@ dependencies = [
[[package]] [[package]]
name = "erased-serde" name = "erased-serde"
version = "0.3.13" version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0465971a8cc1fa2455c8465aaa377131e1f1cf4983280f474a13e68793aa770c" checksum = "e5b36e6f2295f393f44894c6031f67df4d185b984cd54d08f768ce678007efcd"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -1156,9 +1156,9 @@ checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
[[package]] [[package]]
name = "httpdate" name = "httpdate"
version = "1.0.0" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05842d0d43232b23ccb7060ecb0f0626922c21f30012e97b767b30afd4a5d4b9" checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440"
[[package]] [[package]]
name = "humantime" name = "humantime"
@ -1195,9 +1195,9 @@ dependencies = [
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.14.7" version = "0.14.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e5f105c494081baa3bf9e200b279e27ec1623895cd504c7dbef8d0b080fcf54" checksum = "d3f71a7eea53a3f8257a7b4795373ff886397178cd634430ea94e12d7fe4fe34"
dependencies = [ dependencies = [
"bytes 1.0.1", "bytes 1.0.1",
"futures-channel", "futures-channel",
@ -1207,7 +1207,7 @@ dependencies = [
"http", "http",
"http-body 0.4.2", "http-body 0.4.2",
"httparse", "httparse",
"httpdate 1.0.0", "httpdate 1.0.1",
"itoa", "itoa",
"pin-project", "pin-project",
"socket2 0.4.0", "socket2 0.4.0",
@ -1237,7 +1237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [ dependencies = [
"bytes 1.0.1", "bytes 1.0.1",
"hyper 0.14.7", "hyper 0.14.8",
"native-tls", "native-tls",
"tokio 1.6.0", "tokio 1.6.0",
"tokio-native-tls", "tokio-native-tls",
@ -1457,10 +1457,11 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]] [[package]]
name = "marine" name = "marine"
version = "0.6.4" version = "0.6.5"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"anyhow", "anyhow",
"atty",
"check-latest", "check-latest",
"clap", "clap",
"exitfailure", "exitfailure",
@ -2464,7 +2465,7 @@ dependencies = [
"futures-util", "futures-util",
"http", "http",
"http-body 0.4.2", "http-body 0.4.2",
"hyper 0.14.7", "hyper 0.14.8",
"hyper-tls 0.5.0", "hyper-tls 0.5.0",
"ipnet", "ipnet",
"js-sys", "js-sys",
@ -2883,18 +2884,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.24" version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.24" version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -3219,9 +3220,9 @@ dependencies = [
[[package]] [[package]]
name = "vcpkg" name = "vcpkg"
version = "0.2.12" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbdbff6266a24120518560b5dc983096efb98462e51d0d68169895b237be3e5d" checksum = "025ce40a007e1907e58d5bc1a594def78e5573bb0b1160bc389634e8f12e4faa"
[[package]] [[package]]
name = "vec_map" name = "vec_map"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "marine" name = "marine"
description = "Fluence Marine command line tool" description = "Fluence Marine command line tool"
version = "0.6.4" version = "0.6.5"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
repository = "https://github.com/fluencelabs/marine/tools/cli" repository = "https://github.com/fluencelabs/marine/tools/cli"
license = "Apache-2.0" license = "Apache-2.0"
@ -20,6 +20,7 @@ semver = "0.11.0"
walrus = "0.18.0" walrus = "0.18.0"
Inflector = "0.11.4" Inflector = "0.11.4"
atty = "0.2.14"
thiserror = "1.0.24" thiserror = "1.0.24"
anyhow = "1.0.31" anyhow = "1.0.31"
check-latest = "1.0.0" check-latest = "1.0.0"

View File

@ -48,7 +48,10 @@ pub fn main() -> Result<(), anyhow::Error> {
let arg_matches = app.get_matches(); let arg_matches = app.get_matches();
match arg_matches.subcommand() { match arg_matches.subcommand() {
("aqua", Some(args)) => aqua(args), ("aqua", Some(args)) => {
// avoid printing version
return aqua(args);
}
("build", Some(args)) => build(args), ("build", Some(args)) => build(args),
("set", Some(args)) => set(args), ("set", Some(args)) => set(args),
("it", Some(args)) => it(args), ("it", Some(args)) => it(args),
@ -57,6 +60,11 @@ pub fn main() -> Result<(), anyhow::Error> {
(c, _) => Err(crate::errors::CLIError::NoSuchCommand(c.to_string()).into()), (c, _) => Err(crate::errors::CLIError::NoSuchCommand(c.to_string()).into()),
}?; }?;
// avoid printing version update into not TTY targets
if !atty::is(atty::Stream::Stdout) {
return Ok(());
}
if let Ok(Some(new_version)) = check_latest::check_max!() { if let Ok(Some(new_version)) = check_latest::check_max!() {
use termion::color; use termion::color;