diff --git a/kuksa_databroker/databroker-cli/src/sdv_cli.rs b/kuksa_databroker/databroker-cli/src/sdv_cli.rs index 7d79cc52..52428323 100644 --- a/kuksa_databroker/databroker-cli/src/sdv_cli.rs +++ b/kuksa_databroker/databroker-cli/src/sdv_cli.rs @@ -68,8 +68,8 @@ fn print_usage(command: impl AsRef) { } } -pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ - let mut _properties = Vec::::new(); +pub async fn sdv_main(_cli: Cli) -> Result<(), Box> { + let mut properties = Vec::::new(); println!("Using {VERSION}"); let mut cli = _cli; @@ -162,6 +162,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ Ok(metadata) => { interface .set_completer(Arc::new(CliCompleter::from_metadata(&metadata))); + properties = metadata; } Err(common::ClientError::Status(status)) => { cli::print_resp_err("metadata", &status)?; @@ -240,7 +241,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ interface.set_completer(Arc::new( CliCompleter::from_metadata(&metadata), )); - _properties = metadata; + properties = metadata; } Err(common::ClientError::Status(status)) => { cli::print_resp_err("metadata", &status)?; @@ -277,7 +278,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ interface.set_completer(Arc::new( CliCompleter::from_metadata(&metadata), )); - _properties = metadata; + properties = metadata; } Err(common::ClientError::Status(status)) => { cli::print_resp_err("metadata", &status)?; @@ -318,7 +319,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ let datapoint_metadata = { let mut datapoint_metadata = None; - for metadata in _properties.iter() { + for metadata in properties.iter() { if metadata.name == path { datapoint_metadata = Some(metadata) } @@ -421,7 +422,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ let datapoint_metadata = { let mut datapoint_metadata = None; - for metadata in _properties.iter() { + for metadata in properties.iter() { if metadata.name == path { datapoint_metadata = Some(metadata) } @@ -645,7 +646,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ interface.set_completer(Arc::new( CliCompleter::from_metadata(&metadata), )); - _properties = metadata; + properties = metadata; } Err(common::ClientError::Status(status)) => { cli::print_resp_err("metadata", &status)?; @@ -669,10 +670,10 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ match client.get_metadata(vec![]).await { Ok(mut metadata) => { metadata.sort_by(|a, b| a.name.cmp(&b.name)); - _properties = metadata; - interface.set_completer(Arc::new( - CliCompleter::from_metadata(&_properties), - )); + properties = metadata; + interface.set_completer(Arc::new(CliCompleter::from_metadata( + &properties, + ))); cli::print_resp_ok(cmd)?; } Err(common::ClientError::Status(status)) => { @@ -691,12 +692,12 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box>{ let mut filtered_metadata = Vec::new(); if paths.is_empty() { cli::print_info("If you want to list metadata of signals, use `metadata PATTERN`")?; - // filtered_metadata.extend(&_properties); + // filtered_metadata.extend(&properties); } else { for path in &paths { let path_re = path_to_regex(path); let filtered = - _properties.iter().filter(|item| match &path_re { + properties.iter().filter(|item| match &path_re { Ok(re) => re.is_match(&item.name), Err(err) => { cli::print_info(format!("Invalid path: {err}"))