Skip to content

Commit 30ba164

Browse files
AntosserLeoBorai
andauthored
feat: replace --verbose with --quiet (#370)
* Replace --verbose with --quiet * Replaced last remaining "verbose" with "quiet" * Fix capitalization of "Print" * fix: spacing in readme * Run "cargo clippy --fix" --------- Co-authored-by: Esteban Borai <[email protected]>
1 parent e13e59f commit 30ba164

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ FLAGS:
4848
--logger Prints HTTP request and response details to stdout
4949
--tls Enables HTTPS serving using TLS
5050
-V, --version Prints version information
51-
-v, --verbose Turns on stdout/stderr logging
51+
-q, --quiet Turns off stdout/stderr logging
5252
5353
OPTIONS:
5454
-c, --config <config> Path to TOML configuration file
@@ -84,7 +84,7 @@ Configuration File | Specifies a configuration file. [Example](https://github.co
8484
HTTPS (TLS) | HTTPS Secure connection configuration. Refer to [TLS (HTTPS)](https://github.com/http-server-rs/http-server#tls-https) reference | Disabled
8585
CORS | Cross-Origin-Resource-Sharing headers support. Refer to [CORS](https://github.com/http-server-rs/http-server#cross-origin-resource-sharing-cors) reference | Disabled
8686
Compression | GZip compression for HTTP Response Bodies. Refer to [Compression](https://github.com/http-server-rs/http-server#compression) reference | Disabled
87-
Verbose | Print server details when running. This doesn't include any logging capabilities. | Disabled
87+
Quiet | Don't print server details when running. This doesn't include any logging capabilities. | Disabled
8888
Basic Authentication | Authorize requests using Basic Authentication. Refer to [Basic Authentication](https://github.com/http-server-rs/http-server#basic-authentication) | Disabled
8989
Logger | Prints HTTP request and response details to stdout | Disabled
9090

@@ -110,7 +110,7 @@ Graceful Shutdown | N/A | `--graceful-shutdown` | Wait for all requests to be fu
110110
Help | N/A | `--help` | Print help information
111111
Logger | `-l` | `--logger` | Print HTTP request and response details to stdout
112112
Version | `-V` | `--version` | Print version information
113-
Verbose | `-v` | `--verbose` | Print output to console
113+
Quiet | `-q` | `--quiet` | Don't print output to console
114114

115115
### Options
116116

fixtures/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
host = "127.0.0.1"
55
port = 7878
66

7-
# verbose = false
7+
# quiet = false
88
# root_dir = "./"
99
# graceful_shutdown = false
1010

rustfmt.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Use verbose output.
1+
# Use quiet output.
22
# Default: false
3-
# verbose =
3+
# quiet =
44

55
# Do not reformat out of line modules.
66
# Default: false
@@ -275,4 +275,4 @@
275275

276276
# Replace strings of _ wildcards by a single .. in tuple patterns.
277277
# Default: false
278-
# condense_wildcard_suffices =
278+
# condense_wildcard_suffices =

src/cli.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ pub struct Cli {
2424
/// Directory to serve files from
2525
#[structopt(parse(from_os_str), default_value = "./")]
2626
pub root_dir: PathBuf,
27-
/// Turns on stdout/stderr logging
28-
#[structopt(short = "v", long = "verbose")]
29-
pub verbose: bool,
27+
/// Turns off stdout/stderr logging
28+
#[structopt(short = "q", long = "quiet")]
29+
pub quiet: bool,
3030
/// Enables HTTPS serving using TLS
3131
#[structopt(long = "tls")]
3232
pub tls: bool,
@@ -75,7 +75,7 @@ impl Default for Cli {
7575
host: "127.0.0.1".parse().unwrap(),
7676
port: 7878_u16,
7777
root_dir: PathBuf::from_str("./").unwrap(),
78-
verbose: false,
78+
quiet: false,
7979
tls: false,
8080
tls_cert: PathBuf::from_str("cert.pem").unwrap(),
8181
tls_key: PathBuf::from_str("key.rsa").unwrap(),
@@ -142,11 +142,11 @@ mod tests {
142142
}
143143

144144
#[test]
145-
fn with_verbose() {
146-
let from_args = Cli::from_str_args(vec!["http-server", "--verbose"]);
145+
fn with_quiet() {
146+
let from_args = Cli::from_str_args(vec!["http-server", "--quiet"]);
147147
let mut expect = Cli::default();
148148

149-
expect.verbose = true;
149+
expect.quiet = true;
150150

151151
assert_eq!(from_args, expect);
152152
}

src/config/file.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::tls::TlsConfigFile;
1515
pub struct ConfigFile {
1616
pub host: IpAddr,
1717
pub port: u16,
18-
pub verbose: Option<bool>,
18+
pub quiet: Option<bool>,
1919
#[serde(default = "current_working_dir")]
2020
#[serde(deserialize_with = "canonicalize_some")]
2121
pub root_dir: Option<PathBuf>,
@@ -76,7 +76,7 @@ mod tests {
7676
let file_contents = r#"
7777
host = "192.168.0.1"
7878
port = 7878
79-
verbose = true
79+
quiet = true
8080
root_dir = "./fixtures"
8181
"#;
8282
let host = IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1));
@@ -91,7 +91,7 @@ mod tests {
9191
assert!(config.compression.is_none());
9292
assert_eq!(config.host, host);
9393
assert_eq!(config.port, port);
94-
assert_eq!(config.verbose, Some(true));
94+
assert_eq!(config.quiet, Some(true));
9595
assert_eq!(config.root_dir, Some(root_dir));
9696
}
9797

@@ -111,7 +111,7 @@ mod tests {
111111
let file_contents = r#"
112112
host = "192.168.0.1"
113113
port = 7878
114-
verbose = false
114+
quiet = false
115115
116116
[tls]
117117
cert = "cert_123.pem"
@@ -132,7 +132,7 @@ mod tests {
132132
assert_eq!(config.port, port);
133133
assert_eq!(config.root_dir, root_dir);
134134
assert_eq!(config.tls.unwrap(), tls);
135-
assert_eq!(config.verbose, Some(false));
135+
assert_eq!(config.quiet, Some(false));
136136
}
137137

138138
#[test]

src/config/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct Config {
2727
host: IpAddr,
2828
port: u16,
2929
root_dir: PathBuf,
30-
verbose: bool,
30+
quiet: bool,
3131
tls: Option<TlsConfig>,
3232
cors: Option<CorsConfig>,
3333
compression: Option<CompressionConfig>,
@@ -54,8 +54,8 @@ impl Config {
5454
self.root_dir.clone()
5555
}
5656

57-
pub fn verbose(&self) -> bool {
58-
self.verbose
57+
pub fn quiet(&self) -> bool {
58+
self.quiet
5959
}
6060

6161
pub fn tls(&self) -> Option<TlsConfig> {
@@ -99,7 +99,7 @@ impl Default for Config {
9999
port,
100100
address,
101101
root_dir,
102-
verbose: false,
102+
quiet: false,
103103
tls: None,
104104
cors: None,
105105
compression: None,
@@ -115,7 +115,7 @@ impl TryFrom<Cli> for Config {
115115
type Error = anyhow::Error;
116116

117117
fn try_from(cli_arguments: Cli) -> Result<Self, Self::Error> {
118-
let verbose = cli_arguments.verbose;
118+
let quiet = cli_arguments.quiet;
119119
let root_dir = if cli_arguments.root_dir.to_str().unwrap() == "./" {
120120
current_dir().unwrap()
121121
} else {
@@ -181,7 +181,7 @@ impl TryFrom<Cli> for Config {
181181
port: cli_arguments.port,
182182
address: SocketAddr::new(cli_arguments.host, cli_arguments.port),
183183
root_dir,
184-
verbose,
184+
quiet,
185185
tls,
186186
cors,
187187
compression,
@@ -198,7 +198,7 @@ impl TryFrom<ConfigFile> for Config {
198198

199199
fn try_from(file: ConfigFile) -> Result<Self, Self::Error> {
200200
let root_dir = file.root_dir.unwrap_or_default();
201-
let verbose = file.verbose.unwrap_or(false);
201+
let quiet = file.quiet.unwrap_or(false);
202202
let tls: Option<TlsConfig> = if let Some(https_config) = file.tls {
203203
Some(TlsConfig::new(
204204
https_config.cert,
@@ -213,7 +213,7 @@ impl TryFrom<ConfigFile> for Config {
213213
host: file.host,
214214
port: file.port,
215215
address: SocketAddr::new(file.host, file.port),
216-
verbose,
216+
quiet,
217217
root_dir,
218218
tls,
219219
cors: file.cors,
@@ -249,6 +249,6 @@ mod tests {
249249
"default socket address: {}",
250250
address
251251
);
252-
assert!(!config.verbose, "verbose is off by default");
252+
assert!(!config.quiet, "quiet is off by default");
253253
}
254254
}

src/server/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Server {
7373
}
7474
}));
7575

76-
if self.config.verbose() {
76+
if !self.config.quiet() {
7777
println!("Serving HTTP: http://{}", address);
7878

7979
if self.config.address().ip() == Ipv4Addr::from_str("0.0.0.0").unwrap() {
@@ -118,7 +118,7 @@ impl Server {
118118
}
119119
}));
120120

121-
if self.config.verbose() {
121+
if !self.config.quiet() {
122122
println!("Serving HTTPS: http://{}", address);
123123

124124
if self.config.address().ip() == Ipv4Addr::from_str("0.0.0.0").unwrap() {

0 commit comments

Comments
 (0)