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

Function parse

rust/crates/ccusage/src/cli.rs:7–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5use crate::{DEFAULT_SESSION_DURATION_HOURS, config::ConfigContext};
6
7pub(crate) fn parse() -> Cli {
8 let args = env::args_os().collect::<Vec<_>>();
9 let arg_strings = args_to_strings(args.iter().skip(1).cloned()).unwrap_or_else(|message| {
10 eprintln!("{message}");
11 eprintln!("Run 'ccusage --help' for usage.");
12 process::exit(2);
13 });
14 let config = ConfigContext::from_args(&arg_strings);
15 Cli::parse_from_with_config(
16 args,
17 &config,
18 DEFAULT_SESSION_DURATION_HOURS,
19 env!("CARGO_PKG_VERSION"),
20 )
21 .unwrap_or_else(|message| {
22 eprintln!("{message}");
23 eprintln!("Run 'ccusage --help' for usage.");
24 process::exit(2);
25 })
26}
27
28fn args_to_strings<I>(args: I) -> Result<Vec<String>, String>
29where

Calls 1

args_to_stringsFunction · 0.85