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

Method next_flag

rust/crates/ccusage-cli/src/arg_parser.rs:35–52  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

33 }
34
35 pub(crate) fn next_flag(&mut self) -> Result<String, String> {
36 self.pending_value = None;
37 let arg = self
38 .next()
39 .ok_or_else(|| "Expected option but reached end of arguments".to_string())?;
40 if let Some((flag, value)) = arg.split_once('=') {
41 if !flag.starts_with('-') {
42 return Err(format!("Expected option, got '{arg}'"));
43 }
44 self.pending_value = Some(value.to_string());
45 return Ok(flag.to_string());
46 }
47 if arg.starts_with('-') {
48 Ok(arg)
49 } else {
50 Err(format!("Expected option, got '{arg}'"))
51 }
52 }
53
54 pub(crate) fn value_for(&mut self, flag: &str) -> Result<String, String> {
55 if let Some(value) = self.pending_value.take() {

Callers 9

parse_commandFunction · 0.80
parse_codex_commandFunction · 0.80
parse_pi_commandFunction · 0.80
parse_openclaw_commandFunction · 0.80
parse_shared_argFunction · 0.80

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected