瀏覽代碼

created dummy cli for cashier

lunar-mining 5 年之前
父節點
當前提交
cd0616af51
共有 5 個文件被更改,包括 60 次插入13 次删除
  1. 53 10
      src/cli/cashierd_cli.rs
  2. 0 1
      src/cli/cli_config.rs
  3. 5 0
      src/rpc/jsonserver.rs
  4. 1 1
      src/service/btc.rs
  5. 1 1
      src/service/cashier.rs

+ 53 - 10
src/cli/cashierd_cli.rs

@@ -1,25 +1,68 @@
 use crate::Result;
+use clap::{App, Arg};
 
 pub struct CashierdCli {
     pub verbose: bool,
+    pub hello: bool,
     pub wallet: bool,
     pub info: bool,
-    pub hello: bool,
     pub stop: bool,
 }
 
 impl CashierdCli {
     pub fn load() -> Result<Self> {
-        let app = clap_app!(dfi =>
-            (version: "0.1.0")
-            (author: "Dark Renaissance Technologies")
-            (about: "run service daemon")
-            (@arg VERBOSE: -v --verbose "Increase verbosity")
-        )
-        .get_matches();
+        let app = App::new("Cashier CLI")
+            .version("0.1.0")
+            .author("Dark Renaissance Technologies")
+            .about("run service daemon")
+            .arg(
+                Arg::new("verbose")
+                    .short('v')
+                    .help_heading(Some("Increase verbosity"))
+                    .long("verbose")
+                    .takes_value(false),
+            )
+            .arg(
+                Arg::new("hello")
+                    .long("hello")
+                    .help_heading(Some("Say hello"))
+                    .takes_value(false),
+            )
+            .arg(
+                Arg::new("wallet")
+                    .short('w')
+                    .long("wallet")
+                    .help_heading(Some("Create a new wallet"))
+                    .takes_value(false),
+            )
+            .arg(
+                Arg::new("info")
+                    .short('i')
+                    .long("info")
+                    .help_heading(Some("Request info from daemon"))
+                    .takes_value(false),
+            )
+            .arg(
+                Arg::new("stop")
+                    .short('s')
+                    .long("stop")
+                    .help_heading(Some("Send a stop signal to the daemon"))
+                    .takes_value(false),
+            )
+            .get_matches();
 
-        let verbose = app.is_present("VERBOSE");
+        let verbose = app.is_present("verbose");
+        let wallet = app.is_present("wallet");
+        let info = app.is_present("info");
+        let hello = app.is_present("hello");
+        let stop = app.is_present("stop");
 
-        Ok(Self { verbose })
+        Ok(Self {
+            verbose,
+            wallet,
+            info,
+            hello,
+            stop,
+        })
     }
 }

+ 0 - 1
src/cli/cli_config.rs

@@ -195,7 +195,6 @@ pub struct CashierdConfig {
     #[serde(rename = "btc_endpoint")]
     pub btc_endpoint: String,
 
-
     #[serde(default)]
     #[serde(rename = "gateway_url")]
     pub gateway_url: String,

+ 5 - 0
src/rpc/jsonserver.rs

@@ -144,6 +144,11 @@ impl RpcInterface {
             Ok(jsonrpc_core::Value::String("hello world!".into()))
         });
 
+        // TODO: adapter creates these
+        // new handle_input in adapter
+        // handle_input (top leve)
+        // cashier_handle_input() -> adapter -> cashier_wallet
+        // user_handle_input() -> adapter -> user_wallet
         let self1 = self.clone();
         io.add_method("get_key", move |_| {
             let self2 = self1.clone();

+ 1 - 1
src/service/btc.rs

@@ -1,4 +1,4 @@
-use crate::{ Error, Result };
+use crate::{Error, Result};
 
 use rand::distributions::Alphanumeric;
 use rand::{thread_rng, Rng};

+ 1 - 1
src/service/cashier.rs

@@ -2,8 +2,8 @@ use super::reqrep::{PeerId, RepProtocol, Reply, ReqProtocol, Request};
 
 use super::btc::{BitcoinKeys, PubAddress, PubKey};
 //use bitcoin::blockdata::script::Script;
-use electrum_client::{Client, ElectrumApi};
 use electrum_client::bitcoin::Script;
+use electrum_client::{Client, ElectrumApi};
 
 use super::GatewayClient;
 use crate::blockchain::Slab;