mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-21 07:31:34 +03:00
Merge pull request #596 from kinode-dao/hf/terminal-m-caps
terminal: m caps
This commit is contained in:
commit
df6e97b128
@ -13,6 +13,23 @@
|
||||
"grant_capabilities": [
|
||||
"eth:distro:sys",
|
||||
"http-server:distro:sys",
|
||||
"terminal:terminal:sys",
|
||||
{
|
||||
"process": "terminal:terminal:sys",
|
||||
"params": "ReadNameOnly"
|
||||
},
|
||||
{
|
||||
"process": "terminal:terminal:sys",
|
||||
"params": "Read"
|
||||
},
|
||||
{
|
||||
"process": "terminal:terminal:sys",
|
||||
"params": "Add"
|
||||
},
|
||||
{
|
||||
"process": "terminal:terminal:sys",
|
||||
"params": "Remove"
|
||||
},
|
||||
"vfs:distro:sys"
|
||||
],
|
||||
"public": false
|
||||
|
@ -1,5 +1,5 @@
|
||||
use clap::{Arg, Command};
|
||||
use kinode_process_lib::{println, script, Address, Request, SendErrorKind};
|
||||
use kinode_process_lib::{our_capabilities, println, script, Address, Request, SendErrorKind};
|
||||
use regex::Regex;
|
||||
|
||||
wit_bindgen::generate!({
|
||||
@ -10,7 +10,7 @@ wit_bindgen::generate!({
|
||||
const USAGE: &str = "\x1b[1mUsage:\x1b[0m m <target> <body> [-a <await_time>]";
|
||||
|
||||
script!(init);
|
||||
fn init(_our: Address, args: String) -> String {
|
||||
fn init(our: Address, args: String) -> String {
|
||||
if args.is_empty() {
|
||||
return format!("Send a request to a process.\n{USAGE}");
|
||||
}
|
||||
@ -58,7 +58,21 @@ fn init(_our: Address, args: String) -> String {
|
||||
return format!("No body given.\n{USAGE}");
|
||||
};
|
||||
|
||||
let req = Request::new().target(target).body(body.as_bytes().to_vec());
|
||||
let target = if target.node() != "our" {
|
||||
target
|
||||
} else {
|
||||
Address::new(our.node(), target.process)
|
||||
};
|
||||
|
||||
let capabilities = our_capabilities()
|
||||
.into_iter()
|
||||
.filter(|cap| cap.issuer == target)
|
||||
.collect();
|
||||
|
||||
let req = Request::new()
|
||||
.target(target)
|
||||
.body(body.as_bytes().to_vec())
|
||||
.capabilities(capabilities);
|
||||
|
||||
match parsed.get_one::<u64>("await") {
|
||||
Some(s) => {
|
||||
|
@ -6,7 +6,6 @@
|
||||
"request_networking": true,
|
||||
"request_capabilities": [
|
||||
"app-store:app-store:sys",
|
||||
"contacts:contacts:sys",
|
||||
"chess:chess:sys",
|
||||
"eth:distro:sys",
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user