Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch & fetchpost: better --report option handling #451

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/cmd/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Fetch options:
fetch_url - URL used, fetch_status - HTTP code, fetch_cache_hit - cache hit flag,
fetch_retries - retry attempts, fetch_elapsed - elapsed time & fetch_response.
The short report only has the six columns without the "qsv_fetch_" prefix.
[default: none]
--redis Use Redis to cache responses. It connects to "redis://127.0.0.1:6379/1"
with a connection pool size of 20, with a TTL of 28 days, and a cache hit
NOT renewing an entry's TTL.
Expand Down Expand Up @@ -206,7 +207,7 @@ struct Args {
flag_store_error: bool,
flag_cache_error: bool,
flag_cookies: bool,
flag_report: Option<String>,
flag_report: String,
flag_redis: bool,
flag_flushdb: bool,
flag_output: Option<String>,
Expand Down Expand Up @@ -475,14 +476,12 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}

// prepare report
let report = if let Some(reportkind) = args.flag_report {
if reportkind.to_lowercase().starts_with('d') {
// if it starts with d, its a detailed report
ReportKind::Detailed
} else {
// defaults to short if --report option is anything else
ReportKind::Short
}
let report = if args.flag_report.to_lowercase().starts_with('d') {
// if it starts with d, its a detailed report
ReportKind::Detailed
} else if args.flag_report.to_lowercase().starts_with('s') {
// if it starts with s, its a short report
ReportKind::Short
} else {
ReportKind::None
};
Expand Down
17 changes: 8 additions & 9 deletions src/cmd/fetchpost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Fetch options:
fetchp_cache_hit - cached hit flag, fetchp_retries - retry attempts,
fetchp_elapsed - elapsed time & fetchp_response.
The short report only has the sevenn columns without the "qsv_fetchp_" prefix.
[default: none]
--redis Use Redis to cache responses. It connects to "redis://127.0.0.1:6379/2"
with a connection pool size of 20, with a TTL of 28 days, and a cache hit
NOT renewing an entry's TTL.
Expand Down Expand Up @@ -181,7 +182,7 @@ struct Args {
flag_store_error: bool,
flag_cache_error: bool,
flag_cookies: bool,
flag_report: Option<String>,
flag_report: String,
flag_redis: bool,
flag_flushdb: bool,
flag_output: Option<String>,
Expand Down Expand Up @@ -438,14 +439,12 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}

// prepare report
let report = if let Some(reportkind) = args.flag_report {
if reportkind.to_ascii_lowercase().starts_with('d') {
// if it starts with d, its a detailed report
ReportKind::Detailed
} else {
// defaults to short if --report option is anything else
ReportKind::Short
}
let report = if args.flag_report.to_lowercase().starts_with('d') {
// if it starts with d, its a detailed report
ReportKind::Detailed
} else if args.flag_report.to_lowercase().starts_with('s') {
// if it starts with s, its a short report
ReportKind::Short
} else {
ReportKind::None
};
Expand Down