diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2018-01-23 18:30:11 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2018-01-23 18:30:11 -0500 |
commit | c2f1199de55897cc98d7663f171329a04e63b230 (patch) | |
tree | 37d5fcd052f9fce50eacae78633cf09a1c8a9901 /ipfs-cli/src | |
parent | 06a3776548b8c81226ef61715e5a2e98e29799c9 (diff) |
formatting
Diffstat (limited to 'ipfs-cli/src')
-rw-r--r-- | ipfs-cli/src/command/add.rs | 2 | ||||
-rw-r--r-- | ipfs-cli/src/command/bitswap.rs | 2 | ||||
-rw-r--r-- | ipfs-cli/src/command/block.rs | 9 | ||||
-rw-r--r-- | ipfs-cli/src/command/bootstrap.rs | 34 | ||||
-rw-r--r-- | ipfs-cli/src/command/cat.rs | 8 | ||||
-rw-r--r-- | ipfs-cli/src/command/commands.rs | 3 | ||||
-rw-r--r-- | ipfs-cli/src/command/config.rs | 2 | ||||
-rw-r--r-- | ipfs-cli/src/command/dag.rs | 2 | ||||
-rw-r--r-- | ipfs-cli/src/command/dht.rs | 10 | ||||
-rw-r--r-- | ipfs-cli/src/command/diag.rs | 46 | ||||
-rw-r--r-- | ipfs-cli/src/command/dns.rs | 2 | ||||
-rw-r--r-- | ipfs-cli/src/command/file.rs | 2 | ||||
-rw-r--r-- | ipfs-cli/src/command/files.rs | 8 | ||||
-rw-r--r-- | ipfs-cli/src/command/filestore.rs | 9 | ||||
-rw-r--r-- | ipfs-cli/src/command/mod.rs | 3 | ||||
-rw-r--r-- | ipfs-cli/src/command/version.rs | 7 |
16 files changed, 52 insertions, 97 deletions
diff --git a/ipfs-cli/src/command/add.rs b/ipfs-cli/src/command/add.rs index 40eeb3c..d732091 100644 --- a/ipfs-cli/src/command/add.rs +++ b/ipfs-cli/src/command/add.rs @@ -12,7 +12,6 @@ use ipfs_api::IpfsClient; use std::fs::File; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand add => @@ -21,7 +20,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { let path = args.value_of("INPUT").unwrap(); let file = File::open(path).expect(EXPECTED_FILE); diff --git a/ipfs-cli/src/command/bitswap.rs b/ipfs-cli/src/command/bitswap.rs index ed76107..33f88ef 100644 --- a/ipfs-cli/src/command/bitswap.rs +++ b/ipfs-cli/src/command/bitswap.rs @@ -11,7 +11,6 @@ use command::EXPECTED_API; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand bitswap => @@ -33,7 +32,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("ledger", Some(args)) => { diff --git a/ipfs-cli/src/command/block.rs b/ipfs-cli/src/command/block.rs index 09bc660..7cccb5b 100644 --- a/ipfs-cli/src/command/block.rs +++ b/ipfs-cli/src/command/block.rs @@ -14,7 +14,6 @@ use std::fs::File; use std::io::{self, Write}; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand block => @@ -38,14 +37,13 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("get", Some(args)) => { let key = args.value_of("KEY").unwrap(); - let req = client.block_get(key).for_each(|chunk| { - io::stdout().write_all(&chunk).map_err(From::from) - }); + let req = client + .block_get(key) + .for_each(|chunk| io::stdout().write_all(&chunk).map_err(From::from)); core.run(req).expect(EXPECTED_API); } @@ -81,5 +79,4 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { } _ => unreachable!(), } - } diff --git a/ipfs-cli/src/command/bootstrap.rs b/ipfs-cli/src/command/bootstrap.rs index fea60de..dc3014e 100644 --- a/ipfs-cli/src/command/bootstrap.rs +++ b/ipfs-cli/src/command/bootstrap.rs @@ -11,7 +11,6 @@ use command::EXPECTED_API; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand bootstrap => @@ -34,7 +33,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - fn print_peers(peers: &[String]) { println!(); println!(" peers :"); @@ -44,36 +42,30 @@ fn print_peers(peers: &[String]) { println!(); } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { - ("add", Some(add)) => { - match add.subcommand() { - ("default", _) => { - let peers = core.run(client.bootstrap_add_default()).expect( - EXPECTED_API, - ); + ("add", Some(add)) => match add.subcommand() { + ("default", _) => { + let peers = core.run(client.bootstrap_add_default()) + .expect(EXPECTED_API); - print_peers(&peers.peers); - } - _ => unreachable!(), + print_peers(&peers.peers); } - } + _ => unreachable!(), + }, ("list", _) => { let peers = core.run(client.bootstrap_list()).expect(EXPECTED_API); print_peers(&peers.peers); } - ("rm", Some(rm)) => { - match rm.subcommand() { - ("all", _) => { - let peers = core.run(client.bootstrap_rm_all()).expect(EXPECTED_API); + ("rm", Some(rm)) => match rm.subcommand() { + ("all", _) => { + let peers = core.run(client.bootstrap_rm_all()).expect(EXPECTED_API); - print_peers(&peers.peers); - } - _ => unreachable!(), + print_peers(&peers.peers); } - } + _ => unreachable!(), + }, _ => unreachable!(), } } diff --git a/ipfs-cli/src/command/cat.rs b/ipfs-cli/src/command/cat.rs index 5bab711..1f77306 100644 --- a/ipfs-cli/src/command/cat.rs +++ b/ipfs-cli/src/command/cat.rs @@ -13,7 +13,6 @@ use ipfs_api::IpfsClient; use std::io::{self, Write}; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand cat => @@ -22,12 +21,11 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { let path = args.value_of("PATH").unwrap(); - let req = client.cat(path).for_each(|chunk| { - io::stdout().write_all(&chunk).map_err(From::from) - }); + let req = client + .cat(&path) + .for_each(|chunk| io::stdout().write_all(&chunk).map_err(From::from)); core.run(req).expect(EXPECTED_API); } diff --git a/ipfs-cli/src/command/commands.rs b/ipfs-cli/src/command/commands.rs index 05f787c..ffba5f2 100644 --- a/ipfs-cli/src/command/commands.rs +++ b/ipfs-cli/src/command/commands.rs @@ -12,7 +12,6 @@ use ipfs_api::IpfsClient; use ipfs_api::response::CommandsResponse; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand commands => @@ -20,7 +19,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - fn recursive_print_commands(cmd: CommandsResponse, stack: &mut Vec<String>) { if cmd.subcommands.is_empty() { println!(" {} {}", stack.join(" "), cmd.name); @@ -37,7 +35,6 @@ fn recursive_print_commands(cmd: CommandsResponse, stack: &mut Vec<String>) { } } - pub fn handle(core: &mut Core, client: &IpfsClient) { let commands = core.run(client.commands()).expect(EXPECTED_API); diff --git a/ipfs-cli/src/command/config.rs b/ipfs-cli/src/command/config.rs index dad83a1..e778816 100644 --- a/ipfs-cli/src/command/config.rs +++ b/ipfs-cli/src/command/config.rs @@ -12,7 +12,6 @@ use ipfs_api::IpfsClient; use std::fs::File; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand config => @@ -30,7 +29,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("edit", _) => core.run(client.config_edit()).expect(EXPECTED_API), diff --git a/ipfs-cli/src/command/dag.rs b/ipfs-cli/src/command/dag.rs index 81250a5..c2b4f39 100644 --- a/ipfs-cli/src/command/dag.rs +++ b/ipfs-cli/src/command/dag.rs @@ -11,7 +11,6 @@ use command::EXPECTED_API; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand dag => @@ -23,7 +22,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("get", Some(args)) => { diff --git a/ipfs-cli/src/command/dht.rs b/ipfs-cli/src/command/dht.rs index ede7858..9f95d3a 100644 --- a/ipfs-cli/src/command/dht.rs +++ b/ipfs-cli/src/command/dht.rs @@ -13,7 +13,6 @@ use ipfs_api::IpfsClient; use ipfs_api::response::DhtMessage; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand dht => @@ -46,7 +45,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - fn print_dht_response<E>(res: DhtMessage) -> Result<(), E> { println!(); println!(" id : {}", res.id); @@ -66,7 +64,6 @@ fn print_dht_response<E>(res: DhtMessage) -> Result<(), E> { Ok(()) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { let req = match args.subcommand() { ("findpeer", Some(args)) => { @@ -87,7 +84,7 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { ("provide", Some(args)) => { let key = args.value_of("KEY").unwrap(); - client.dht_provide(key) + client.dht_provide(&key) } ("put", Some(args)) => { let key = args.value_of("KEY").unwrap(); @@ -103,7 +100,6 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { _ => unreachable!(), }; - core.run(req.for_each(print_dht_response)).expect( - EXPECTED_API, - ); + core.run(req.for_each(print_dht_response)) + .expect(EXPECTED_API); } diff --git a/ipfs-cli/src/command/diag.rs b/ipfs-cli/src/command/diag.rs index 644de19..7ce6c22 100644 --- a/ipfs-cli/src/command/diag.rs +++ b/ipfs-cli/src/command/diag.rs @@ -11,16 +11,18 @@ use command::EXPECTED_API; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { // The clap macro does not allow hyphenated command names, // so the `set-time` command has to be manually instantiated. // let set_time_command = SubCommand::with_name("set-time") .about("Set how long to keep inactive requests in the log") - .arg(Arg::with_name("TIME").required(true).index(1).help( - "Time to keep inactive requests in the log", - )); + .arg( + Arg::with_name("TIME") + .required(true) + .index(1) + .help("Time to keep inactive requests in the log"), + ); clap_app!( @subcommand diag => @@ -38,32 +40,28 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { - ("cmds", Some(args)) => { - match args.subcommand() { - ("clear", _) => { - core.run(client.diag_cmds_clear()).expect(EXPECTED_API); + ("cmds", Some(args)) => match args.subcommand() { + ("clear", _) => { + core.run(client.diag_cmds_clear()).expect(EXPECTED_API); - println!(); - println!(" OK"); - println!(); - } - ("set-time", Some(args)) => { - let time = args.value_of("TIME").unwrap(); + println!(""); + println!(" OK"); + println!(""); + } + ("set-time", Some(args)) => { + let time = args.value_of("TIME").unwrap(); - core.run(client.diag_cmds_set_time(time)).expect( - EXPECTED_API, - ); + core.run(client.diag_cmds_set_time(&time)) + .expect(EXPECTED_API); - println!(); - println!(" OK"); - println!(); - } - _ => unreachable!(), + println!(""); + println!(" OK"); + println!(""); } - } + _ => unreachable!(), + }, ("sys", _) => { let sys = core.run(client.diag_sys()).expect(EXPECTED_API); diff --git a/ipfs-cli/src/command/dns.rs b/ipfs-cli/src/command/dns.rs index c40f61b..ba5ab94 100644 --- a/ipfs-cli/src/command/dns.rs +++ b/ipfs-cli/src/command/dns.rs @@ -11,7 +11,6 @@ use command::EXPECTED_API; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand dns => @@ -21,7 +20,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { let path = args.value_of("PATH").unwrap(); let req = client.dns(path, args.is_present("recursive")); diff --git a/ipfs-cli/src/command/file.rs b/ipfs-cli/src/command/file.rs index 1d7da87..9fd884a 100644 --- a/ipfs-cli/src/command/file.rs +++ b/ipfs-cli/src/command/file.rs @@ -11,7 +11,6 @@ use command::EXPECTED_API; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand file => @@ -23,7 +22,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("ls", Some(args)) => { diff --git a/ipfs-cli/src/command/files.rs b/ipfs-cli/src/command/files.rs index 1f1564e..9b109c7 100644 --- a/ipfs-cli/src/command/files.rs +++ b/ipfs-cli/src/command/files.rs @@ -14,7 +14,6 @@ use std::fs::File; use std::io::{self, Write}; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand files => @@ -66,7 +65,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("cp", Some(args)) => { @@ -125,9 +123,9 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { } ("read", Some(args)) => { let path = args.value_of("PATH").unwrap(); - let req = client.files_read(path).for_each(|chunk| { - io::stdout().write_all(&chunk).map_err(From::from) - }); + let req = client + .files_read(&path) + .for_each(|chunk| io::stdout().write_all(&chunk).map_err(From::from)); core.run(req).expect(EXPECTED_API); } diff --git a/ipfs-cli/src/command/filestore.rs b/ipfs-cli/src/command/filestore.rs index a14b055..0665a79 100644 --- a/ipfs-cli/src/command/filestore.rs +++ b/ipfs-cli/src/command/filestore.rs @@ -12,7 +12,6 @@ use futures::stream::Stream; use ipfs_api::{response, IpfsClient}; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand filestore => @@ -31,7 +30,6 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - fn print_filestore_object<E>(obj: &response::FilestoreObject) -> Result<(), E> { println!(" status : {}", obj.status); println!(" error_msg : {}", obj.error_msg); @@ -44,7 +42,6 @@ fn print_filestore_object<E>(obj: &response::FilestoreObject) -> Result<(), E> { Ok(()) } - pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { match args.subcommand() { ("dups", _) => { @@ -72,9 +69,9 @@ pub fn handle(core: &mut Core, client: &IpfsClient, args: &ArgMatches) { } ("verify", Some(args)) => { let cid = args.value_of("CID"); - let req = client.filestore_verify(&cid).for_each(|res| { - print_filestore_object(&res) - }); + let req = client + .filestore_verify(&cid) + .for_each(print_filestore_object); println!(); core.run(req).expect(EXPECTED_API); diff --git a/ipfs-cli/src/command/mod.rs b/ipfs-cli/src/command/mod.rs index 7d12053..351bcf6 100644 --- a/ipfs-cli/src/command/mod.rs +++ b/ipfs-cli/src/command/mod.rs @@ -9,11 +9,9 @@ use std::error::Error; use std::fs; - pub const EXPECTED_API: &str = "expected response from API"; pub const EXPECTED_FILE: &str = "expected to read input file"; - /// Verifies that a path points to a file that exists, and not a directory. /// pub fn verify_file(path: String) -> Result<(), String> { @@ -24,7 +22,6 @@ pub fn verify_file(path: String) -> Result<(), String> { } } - pub mod add; pub mod bitswap; pub mod block; diff --git a/ipfs-cli/src/command/version.rs b/ipfs-cli/src/command/version.rs index d8fbafa..eea3f7f 100644 --- a/ipfs-cli/src/command/version.rs +++ b/ipfs-cli/src/command/version.rs @@ -10,7 +10,6 @@ use clap::App; use ipfs_api::IpfsClient; use tokio_core::reactor::Core; - pub fn signature<'a, 'b>() -> App<'a, 'b> { clap_app!( @subcommand version => @@ -18,11 +17,9 @@ pub fn signature<'a, 'b>() -> App<'a, 'b> { ) } - pub fn handle(core: &mut Core, client: &IpfsClient) { - let version = core.run(client.version()).expect( - "expected response from API", - ); + let version = core.run(client.version()) + .expect("expected response from API"); println!(); println!(" version : {}", version.version); |