mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-22 16:11:38 +03:00
parse command-line args using clap
This commit is contained in:
parent
2229d3a80c
commit
a31e94f843
109
Cargo.lock
generated
109
Cargo.lock
generated
@ -112,6 +112,54 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.75"
|
||||
@ -560,6 +608,46 @@ dependencies = [
|
||||
"rlp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim 0.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
|
||||
|
||||
[[package]]
|
||||
name = "coins-bip32"
|
||||
version = "0.8.7"
|
||||
@ -612,6 +700,12 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||
|
||||
[[package]]
|
||||
name = "const-hex"
|
||||
version = "1.8.0"
|
||||
@ -930,7 +1024,7 @@ dependencies = [
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"strsim 0.9.3",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
@ -4266,6 +4360,12 @@ version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.25.0"
|
||||
@ -4846,6 +4946,7 @@ dependencies = [
|
||||
"chacha20poly1305",
|
||||
"chrono",
|
||||
"cita_trie",
|
||||
"clap",
|
||||
"crossterm",
|
||||
"digest 0.10.7",
|
||||
"dotenv",
|
||||
@ -4908,6 +5009,12 @@ version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.8.2"
|
||||
|
@ -24,6 +24,7 @@ cap-std = "2.0.0"
|
||||
chacha20poly1305 = "0.10.1"
|
||||
chrono = "0.4.31"
|
||||
cita_trie = "4.0.0"
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
crossterm = { version = "0.26.1", features = ["event-stream", "bracketed-paste"] }
|
||||
digest = "0.10"
|
||||
dotenv = "0.15.0"
|
||||
@ -65,4 +66,4 @@ uuid = { version = "1.1.2", features = ["serde", "v4"] }
|
||||
warp = "0.3.5"
|
||||
wasmtime = "12.0.1"
|
||||
wasmtime-wasi = "12.0.1"
|
||||
zip = "0.6"
|
||||
zip = "0.6"
|
||||
|
20
src/main.rs
20
src/main.rs
@ -1,4 +1,5 @@
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use dotenv;
|
||||
use ethers::prelude::namehash;
|
||||
use std::env;
|
||||
@ -42,26 +43,15 @@ async fn main() {
|
||||
// For use with https://github.com/tokio-rs/console
|
||||
// console_subscriber::init();
|
||||
|
||||
// DEMO ONLY: remove all CLI arguments
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let home_directory_path = &args[1];
|
||||
// let home_directory_path = "home";
|
||||
// create home directory if it does not already exist
|
||||
let args = types::Args::parse();
|
||||
|
||||
let home_directory_path = &args.home;
|
||||
if let Err(e) = fs::create_dir_all(home_directory_path).await {
|
||||
panic!("failed to create home directory: {:?}", e);
|
||||
}
|
||||
// read PKI from websocket endpoint served by public RPC
|
||||
// if you get rate-limited or something, pass in your own RPC as a boot argument
|
||||
let mut rpc_url = "".to_string();
|
||||
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
if arg == "--rpc" {
|
||||
// Check if the next argument exists and is not another flag
|
||||
if i + 1 < args.len() && !args[i + 1].starts_with('-') {
|
||||
rpc_url = args[i + 1].clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
let rpc_url = args.rpc;
|
||||
|
||||
// kernel receives system messages via this channel, all other modules send messages
|
||||
let (kernel_message_sender, kernel_message_receiver): (MessageSender, MessageReceiver) =
|
||||
|
14
src/types.rs
14
src/types.rs
@ -1,4 +1,5 @@
|
||||
use crate::kernel::component::uq_process::types as wit;
|
||||
use clap::Parser;
|
||||
use ring::signature;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
@ -19,6 +20,19 @@ lazy_static::lazy_static! {
|
||||
pub static ref VFS_PROCESS_ID: ProcessId = ProcessId::new(Some("vfs"), "sys", "uqbar");
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
/// Uqbar: your p2p personal node integrating cryptocurrency and AI
|
||||
#[command(author, version, about, long_about = None)]
|
||||
pub struct Args {
|
||||
/// Home directory
|
||||
#[arg(short, long)]
|
||||
pub home: String,
|
||||
|
||||
/// Ethereum RPC endpoint
|
||||
#[arg(short, long, default_value_t = String::new())]
|
||||
pub rpc: String,
|
||||
}
|
||||
|
||||
//
|
||||
// internal message pipes between kernel and runtime modules
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user