Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 18 additions & 15 deletions kinode/packages/terminal/alias/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use kinode_process_lib::{
await_next_request_body, call_init, println, Address, ProcessId, Request,
};
use serde::{Deserialize, Serialize};
use serde_json::json;

wit_bindgen::generate!({
path: "wit",
Expand All @@ -12,10 +11,12 @@ wit_bindgen::generate!({
},
});

#[derive(Serialize, Deserialize)]
struct EditAliases {
alias: String,
process: Option<ProcessId>,
#[derive(Debug, Serialize, Deserialize)]
enum TerminalAction {
EditAlias {
alias: String,
process: Option<ProcessId>,
},
}

call_init!(init);
Expand All @@ -27,6 +28,12 @@ fn init(_our: Address) {
};

let line = String::from_utf8(args).unwrap_or("alias: error".into());
if line.is_empty() {
println!("Change alias for a process");
println!("\x1b[1mUsage:\x1b[0m alias <alias_name> <process_id>");
return;
}

let (alias, process) = line.split_once(" ").unwrap_or((&line, ""));

if alias.is_empty() {
Expand All @@ -38,13 +45,11 @@ fn init(_our: Address) {
let _ = Request::new()
.target(("our", "terminal", "terminal", "sys"))
.body(
json!(EditAliases {
serde_json::to_vec(&TerminalAction::EditAlias {
alias: alias.to_string(),
process: None
process: None,
})
.to_string()
.as_bytes()
.to_vec(),
.unwrap(),
)
.send();
} else {
Expand All @@ -53,13 +58,11 @@ fn init(_our: Address) {
let _ = Request::new()
.target(("our", "terminal", "terminal", "sys"))
.body(
json!(EditAliases {
serde_json::to_vec(&TerminalAction::EditAlias {
alias: alias.to_string(),
process: Some(process)
process: Some(process),
})
.to_string()
.as_bytes()
.to_vec(),
.unwrap(),
)
.send();
}
Expand Down
8 changes: 7 additions & 1 deletion kinode/packages/terminal/cat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ fn init(_our: Address) {
};

let Ok(file_path) = String::from_utf8(args) else {
println!("bad file path");
println!("cat: bad args, aborting");
return;
};

if file_path.is_empty() {
println!("Print the contents of a file to the terminal");
println!("\x1b[1mUsage:\x1b[0m cat <file_path>");
return;
}

Request::new()
.target(("our", "vfs", "distro", "sys"))
.body(
Expand Down
5 changes: 5 additions & 0 deletions kinode/packages/terminal/hi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ fn init(our: Address) {
};

let tail = String::from_utf8(args).unwrap();
if tail.is_empty() {
println!("Send a Message to another node's terminal");
println!("\x1b[1mUsage:\x1b[0m hi <node_id> <message>");
return;
}

let (node_id, message) = match tail.split_once(" ") {
Some((s, t)) => (s, t),
Expand Down
5 changes: 5 additions & 0 deletions kinode/packages/terminal/m/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ fn init(_our: Address) {
return;
};
let body_string = String::from_utf8(body).unwrap();
if body_string.is_empty() {
println!("Send a Request to a Process");
println!("\x1b[1mUsage:\x1b[0m m <target> <body> [-a <await_time>]");
return;
}

let re = Regex::new(r#"'[^']*'|\S+"#).unwrap();
let mut args: Vec<String> = re
Expand Down
2 changes: 1 addition & 1 deletion kinode/packages/terminal/terminal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
anyhow = "1.0"
bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.5.9-alpha" }
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", tag = "v0.6.0-alpha" }
rand = "0.8"
regex = "1.10.3"
serde = { version = "1.0", features = ["derive"] }
Expand Down
Loading