diff --git a/src/general/cli_handler.rs b/src/general/cli_handler.rs index 8b91863..9356d87 100644 --- a/src/general/cli_handler.rs +++ b/src/general/cli_handler.rs @@ -68,10 +68,10 @@ complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_ complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from update' -a '(cat ~/.detee/cli/vms/uuid_list)' -f complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from inspect' -a '(cat ~/.detee/cli/vms/uuid_list)' -f complete -c detee-cli -n '__fish_detee_cli_using_subcommand vm; and __fish_seen_subcommand_from ssh' -a '(cat ~/.detee/cli/vms/uuid_list)' -f -complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app config update' -a '(cat ~/.detee/cli/apps/uuid_list)' -f -complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app config get' -a '(cat ~/.detee/cli/apps/uuid_list)' -f -complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app delete' -a '(cat ~/.detee/cli/apps/uuid_list)' -f -complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from app inspect' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from update' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from get' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from delete' -a '(cat ~/.detee/cli/apps/uuid_list)' -f +complete -c detee-cli -n '__fish_detee_cli_using_subcommand app; and __fish_seen_subcommand_from inspect' -a '(cat ~/.detee/cli/apps/uuid_list)' -f "#; pub fn handle_completion(matches: &ArgMatches, cmd: Command) { diff --git a/src/sgx/mod.rs b/src/sgx/mod.rs index 4169e28..278d8e4 100644 --- a/src/sgx/mod.rs +++ b/src/sgx/mod.rs @@ -5,10 +5,9 @@ pub mod grpc_dtpm; pub mod packaging; pub mod utils; -use std::sync::LazyLock; - use crate::config::Config; use crate::snp; +use crate::utils::shorten_string; use crate::{constants::HRATLS_APP_PORT, utils::block_on}; use detee_shared::{ app_proto::{ @@ -19,6 +18,7 @@ use detee_shared::{ }; use grpc_brain::get_one_app_node; use serde::{Deserialize, Serialize}; +use std::sync::LazyLock; use tabled::Tabled; #[derive(thiserror::Error, Debug)] @@ -37,7 +37,7 @@ pub enum Error { pub struct AppContract { #[tabled(rename = "Location")] pub location: String, - #[tabled(rename = "UUID")] + #[tabled(rename = "UUID pfx", display_with = "shorten_string")] pub uuid: String, pub name: String, #[tabled(rename = "Cores")] diff --git a/src/snp/mod.rs b/src/snp/mod.rs index 4909701..6d40dbe 100644 --- a/src/snp/mod.rs +++ b/src/snp/mod.rs @@ -3,8 +3,9 @@ pub mod deploy; pub mod grpc; mod injector; pub mod update; -use crate::utils::block_on; +use crate::utils::block_on; +use crate::utils::shorten_string; use crate::{ config::{self, Config}, snp, @@ -169,7 +170,7 @@ impl Distro { pub struct VmContract { #[tabled(rename = "Location")] pub location: String, - #[tabled(rename = "UUID")] + #[tabled(rename = "UUID pfx", display_with = "shorten_string")] pub uuid: String, pub hostname: String, #[tabled(rename = "Cores")] diff --git a/src/utils.rs b/src/utils.rs index 2ebc32d..022da20 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,8 @@ use crate::config::Config; -use tonic::metadata::errors::InvalidMetadataValue; -use tonic::metadata::AsciiMetadataValue; -use tonic::Request; +use tonic::{ + metadata::{errors::InvalidMetadataValue, AsciiMetadataValue}, + Request, +}; #[derive(thiserror::Error, Debug)] pub enum Error { @@ -31,3 +32,13 @@ pub fn sign_request(req: T) -> Result, Error> { req.metadata_mut().insert("request-signature", signature); Ok(req) } + +pub fn shorten_string(my_string: &String) -> String { + if my_string.len() <= 8 { + my_string.to_string() + } else { + let first_part = &my_string[..8]; + // let last_part = &my_string[my_string.len() - 4..]; + format!("{}", first_part) + } +}