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

Function parse_claude_command

rust/crates/ccusage-cli/src/parser.rs:407–438  ·  view source on GitHub ↗
(
    parser: &mut ArgParser,
    shared: SharedArgs,
    config: &dyn CliConfig,
    default_session_duration_hours: f64,
)

Source from the content-addressed store, hash-verified

405}
406
407fn parse_claude_command(
408 parser: &mut ArgParser,
409 shared: SharedArgs,
410 config: &dyn CliConfig,
411 default_session_duration_hours: f64,
412) -> Result<Command, String> {
413 let command = match parser.peek() {
414 Some(command @ ("daily" | "monthly" | "weekly" | "session" | "blocks" | "statusline")) => {
415 let command = command.to_string();
416 parser.next();
417 command
418 }
419 Some(command) if !command.starts_with('-') => {
420 return Err(format!("Unknown claude command '{command}'"));
421 }
422 _ => "daily".to_string(),
423 };
424 match command.as_str() {
425 "daily" => parse_claude_daily_command(parser, shared, config),
426 "monthly" => parse_claude_monthly_command(parser, shared, config),
427 "weekly" => parse_claude_weekly_command(parser, shared, config),
428 "session" => parse_claude_session_command(parser, shared, config),
429 "blocks" | "statusline" => parse_command(
430 &command,
431 parser,
432 shared,
433 config,
434 default_session_duration_hours,
435 ),
436 _ => unreachable!("claude command is prevalidated"),
437 }
438}
439
440fn parse_basic_agent_command(
441 parser: &mut ArgParser,

Callers 1

parse_commandFunction · 0.85

Calls 7

parse_commandFunction · 0.85
peekMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected