MCPcopy Create free account
hub / github.com/ccusage/ccusage / parse_shared_arg

Function parse_shared_arg

rust/crates/ccusage-cli/src/parser.rs:576–608  ·  view source on GitHub ↗
(parser: &mut ArgParser, shared: &mut SharedArgs)

Source from the content-addressed store, hash-verified

574}
575
576fn parse_shared_arg(parser: &mut ArgParser, shared: &mut SharedArgs) -> Result<(), String> {
577 match parser.next_flag()?.as_str() {
578 "-s" | "--since" => {
579 shared.since = Some(normalize_date_bound(&parser.value_for("--since")?))
580 }
581 "-u" | "--until" => {
582 shared.until = Some(normalize_date_bound(&parser.value_for("--until")?))
583 }
584 "-j" | "--json" => shared.json = true,
585 "-m" | "--mode" => shared.mode = parse_cost_mode(&parser.value_for("--mode")?)?,
586 "-d" | "--debug" => shared.debug = true,
587 "--debug-samples" => {
588 shared.debug_samples = parser
589 .value_for("--debug-samples")?
590 .parse()
591 .map_err(|_| "Invalid value for --debug-samples".to_string())?
592 }
593 "-o" | "--order" => shared.order = parse_sort_order(&parser.value_for("--order")?)?,
594 "-b" | "--breakdown" => shared.breakdown = true,
595 "-O" | "--offline" => shared.offline = true,
596 "--no-offline" => shared.no_offline = true,
597 "--color" => shared.color = true,
598 "--no-color" => shared.no_color = true,
599 "-z" | "--timezone" => shared.timezone = Some(parser.value_for("--timezone")?),
600 "-q" | "--jq" => shared.jq = Some(parser.value_for("--jq")?),
601 "--config" => shared.config = Some(PathBuf::from(parser.value_for("--config")?)),
602 "--compact" => shared.compact = true,
603 "--single-thread" => shared.single_thread = true,
604 "--no-cost" => shared.no_cost = true,
605 flag => return Err(format!("Unknown option '{flag}'")),
606 }
607 Ok(())
608}
609
610fn is_command(arg: &str) -> bool {
611 matches!(

Callers 5

parse_all_commandFunction · 0.85

Calls 6

normalize_date_boundFunction · 0.85
parse_cost_modeFunction · 0.85
parse_sort_orderFunction · 0.85
next_flagMethod · 0.80
value_forMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected