(config: &System, options: &ConfigOptions)
| 79 | |
| 80 | #[tracing::instrument(target = "cargo_lambda")] |
| 81 | pub async fn run(config: &System, options: &ConfigOptions) -> Result<()> { |
| 82 | trace!("running config command"); |
| 83 | |
| 84 | if config.setup { |
| 85 | let zig_info = check_installation().await?; |
| 86 | return print_config(config.output_format.as_ref(), zig_info); |
| 87 | } |
| 88 | |
| 89 | let mut info = Info { |
| 90 | zig: get_zig_info()?, |
| 91 | config: None, |
| 92 | }; |
| 93 | let manifest_path = config.manifest_path(); |
| 94 | |
| 95 | if manifest_path.exists() { |
| 96 | let metadata = load_metadata(manifest_path, None)?; |
| 97 | |
| 98 | let config_info = if !options.names.is_empty() || metadata.packages.len() == 1 { |
| 99 | let config = load_config_without_cli_flags(&metadata, options)?; |
| 100 | ConfigInfo::Package(config) |
| 101 | } else { |
| 102 | let (_, _, workspace) = general_config_figment(&metadata, options)?; |
| 103 | |
| 104 | let packages = get_config_from_all_packages(&metadata)?; |
| 105 | |
| 106 | ConfigInfo::Global { |
| 107 | workspace: workspace.extract().into_diagnostic()?, |
| 108 | packages, |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | info.config = Some(config_info); |
| 113 | } |
| 114 | |
| 115 | print_config(config.output_format.as_ref(), info) |
| 116 | } |
| 117 | |
| 118 | fn print_config(format: Option<&OutputFormat>, info: impl Serialize) -> Result<()> { |
| 119 | match format { |
nothing calls this directly
no test coverage detected