Skip to content

Commit

Permalink
touchup interactive cli
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed Nov 6, 2024
1 parent 2bb7b5a commit a287f5e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
4 changes: 0 additions & 4 deletions crates/context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,4 @@ impl ContextManager {

Ok(Some(stream))
}

pub fn is_application_blob_installed(&self, blob_id: BlobId) -> EyreResult<bool> {
self.blob_manager.has(blob_id)
}
}
2 changes: 1 addition & 1 deletion crates/network/src/stream/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ impl<'a> Message<'a> {
}

#[derive(Debug, ThisError)]
#[error("CodecError")]
#[non_exhaustive]
pub enum CodecError {
#[error(transparent)]
StdIo(#[from] IoError),
}

Expand Down
11 changes: 8 additions & 3 deletions crates/node/src/interactive_cli/applications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,21 @@ impl ApplicationCommand {
}
ApplicationSubcommand::Ls => {
println!(
"{ind} {c1:44} | {c2:44} | Source",
"{ind} {c1:44} | {c2:44} | Installed | Source",
c1 = "Application ID",
c2 = "Blob ID",
);
for application in node.ctx_manager.list_installed_applications()? {
let entry = format!(
"{c1:44} | {c2:44} | {c3}",
"{c1:44} | {c2:44} | {c3:9} | {c4}",
c1 = application.id,
c2 = application.blob,
c3 = application.source
c3 = if node.ctx_manager.has_blob_available(application.blob)? {
"Yes"
} else {
"No"
},
c4 = application.source
);
for line in entry.lines() {
println!("{ind} {}", line.cyan());
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/interactive_cli/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ContextCommand {
match self.command {
Commands::Ls => {
println!(
"{c1:44} | {c2:44} | Root Hash",
"{ind} {c1:44} | {c2:44} | Root Hash",
c1 = "Context ID",
c2 = "Application ID",
);
Expand Down
14 changes: 8 additions & 6 deletions crates/node/src/interactive_cli/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ enum IdentitySubcommands {

impl IdentityCommand {
pub fn run(self, node: &Node) -> Result<()> {
let ind = ">>".blue();

match &self.subcommand {
IdentitySubcommands::Ls { context_id } => {
match ContextId::from_str(context_id) {
Expand All @@ -41,7 +43,7 @@ impl IdentityCommand {
Some((k, iter.read()))
};

println!("{:44} | Owned", "Identity");
println!("{ind} {:44} | Owned", "Identity");

for (k, v) in first.into_iter().chain(iter.entries()) {
let (k, v) = (k?, v?);
Expand All @@ -53,23 +55,23 @@ impl IdentityCommand {
let entry = format!(
"{:44} | {}",
k.public_key(),
if v.private_key.is_some() { "*" } else { " " },
if v.private_key.is_some() { "Yes" } else { "No" },
);
for line in entry.lines() {
println!("{}", line.cyan());
println!("{ind} {}", line.cyan());
}
}
}
Err(_) => {
println!("Invalid context ID: {context_id}");
println!("{ind} Invalid context ID: {context_id}");
}
}
}
IdentitySubcommands::New => {
// Handle the "new" subcommand
let identity = node.ctx_manager.new_identity();
println!("Private Key: {}", identity.cyan());
println!("Public Key: {}", identity.public_key().cyan());
println!("{ind} Private Key: {}", identity.cyan());
println!("{ind} Public Key: {}", identity.public_key().cyan());
}
}

Expand Down

0 comments on commit a287f5e

Please sign in to comment.