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

Method parse

ci/lint_cpp_rs/src/lib.rs:1571–1638  ·  view source on GitHub ↗
(args: I)

Source from the content-addressed store, hash-verified

1569
1570impl CliConfig {
1571 fn parse<I>(args: I) -> Result<Self, DynError>
1572 where
1573 I: IntoIterator<Item = String>,
1574 {
1575 let mut output_format = OutputFormat::Text;
1576 let mut project_root = std::env::current_dir()?;
1577 let mut selected_checkers = HashSet::new();
1578 let mut list_checkers = false;
1579 let mut paths = Vec::new();
1580
1581 let mut iter = args.into_iter();
1582 while let Some(arg) = iter.next() {
1583 match arg.as_str() {
1584 "--format" => {
1585 let value = iter.next().ok_or("--format requires json or text")?;
1586 output_format = match value.as_str() {
1587 "json" => OutputFormat::Json,
1588 "text" => OutputFormat::Text,
1589 other => return Err(format!("unsupported --format value: {other}").into()),
1590 };
1591 }
1592 "--project-root" => {
1593 let value = iter.next().ok_or("--project-root requires a path")?;
1594 project_root = PathBuf::from(value).canonicalize()?;
1595 }
1596 "--checker" => {
1597 let value = iter.next().ok_or("--checker requires a checker name")?;
1598 for checker in value.split(',') {
1599 let checker = checker.trim();
1600 if !checker.is_empty() {
1601 selected_checkers.insert(checker.to_string());
1602 }
1603 }
1604 }
1605 "--list-checkers" => list_checkers = true,
1606 "--help" | "-h" => {
1607 print_help();
1608 return Ok(Self {
1609 output_format,
1610 project_root,
1611 selected_checkers: None,
1612 show_help: true,
1613 list_checkers: false,
1614 paths,
1615 });
1616 }
1617 _ if arg.starts_with("--") => {
1618 return Err(format!("unknown argument: {arg}").into());
1619 }
1620 _ => paths.push(arg),
1621 }
1622 }
1623
1624 let selected_checkers = if selected_checkers.is_empty() {
1625 None
1626 } else {
1627 Some(selected_checkers)
1628 };

Callers 4

check_fileFunction · 0.45
check_fileFunction · 0.45
check_fileFunction · 0.45
check_fileFunction · 0.45

Calls 8

print_helpFunction · 0.85
trimMethod · 0.80
nextMethod · 0.45
is_emptyMethod · 0.45
insertMethod · 0.45
to_stringMethod · 0.45
starts_withMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected