(subcommand: &ResourceSubCommand, progress_format: ProgressFormat)
| 550 | |
| 551 | #[allow(clippy::too_many_lines)] |
| 552 | pub fn resource(subcommand: &ResourceSubCommand, progress_format: ProgressFormat) { |
| 553 | let mut dsc = DscManager::new(); |
| 554 | |
| 555 | match subcommand { |
| 556 | ResourceSubCommand::List { resource_name, adapter_name, description, tags, output_format } => { |
| 557 | list_resources(&mut dsc, resource_name, adapter_name.as_ref(), description.as_ref(), tags.as_ref(), output_format.as_ref(), progress_format); |
| 558 | }, |
| 559 | ResourceSubCommand::Schema { resource , version, output_format } => { |
| 560 | if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { |
| 561 | error!("{}: {err}", t!("subcommand.failedDiscoverResource")); |
| 562 | exit(EXIT_DSC_ERROR); |
| 563 | } |
| 564 | resource_command::schema(&mut dsc, resource, version.as_ref(), output_format.as_ref()); |
| 565 | }, |
| 566 | ResourceSubCommand::Export { resource, version, input, file, output_format } => { |
| 567 | if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { |
| 568 | error!("{}: {err}", t!("subcommand.failedDiscoverResource")); |
| 569 | exit(EXIT_DSC_ERROR); |
| 570 | } |
| 571 | let parsed_input = get_input(input.as_ref(), file.as_ref()); |
| 572 | resource_command::export(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref()); |
| 573 | }, |
| 574 | ResourceSubCommand::Get { resource, version, input, file: path, all, output_format } => { |
| 575 | if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { |
| 576 | error!("{}: {err}", t!("subcommand.failedDiscoverResource")); |
| 577 | exit(EXIT_DSC_ERROR); |
| 578 | } |
| 579 | if *all { |
| 580 | resource_command::get_all(&mut dsc, resource, version.as_ref(), output_format.as_ref()); |
| 581 | } |
| 582 | else { |
| 583 | if *output_format == Some(GetOutputFormat::JsonArray) { |
| 584 | error!("{}", t!("subcommand.jsonArrayNotSupported")); |
| 585 | exit(EXIT_INVALID_ARGS); |
| 586 | } |
| 587 | let parsed_input = get_input(input.as_ref(), path.as_ref()); |
| 588 | resource_command::get(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref()); |
| 589 | } |
| 590 | }, |
| 591 | ResourceSubCommand::Set { resource, version, input, file: path, output_format, what_if } => { |
| 592 | if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { |
| 593 | error!("{}: {err}", t!("subcommand.failedDiscoverResource")); |
| 594 | exit(EXIT_DSC_ERROR); |
| 595 | } |
| 596 | let parsed_input = get_input(input.as_ref(), path.as_ref()); |
| 597 | resource_command::set(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref(), *what_if); |
| 598 | }, |
| 599 | ResourceSubCommand::Test { resource, version, input, file: path, output_format } => { |
| 600 | if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { |
| 601 | error!("{}: {err}", t!("subcommand.failedDiscoverResource")); |
| 602 | exit(EXIT_DSC_ERROR); |
| 603 | } |
| 604 | let parsed_input = get_input(input.as_ref(), path.as_ref()); |
| 605 | resource_command::test(&mut dsc, resource, version.as_ref(), &parsed_input, output_format.as_ref()); |
| 606 | }, |
| 607 | ResourceSubCommand::Delete { resource, version, input, file: path, output_format, what_if } => { |
| 608 | if let Err(err) = dsc.find_resources(&[DiscoveryFilter::new(resource, version.clone(), None)], progress_format) { |
| 609 | error!("{}: {err}", t!("subcommand.failedDiscoverResource")); |
no test coverage detected