diff options
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | ipfs-cli/Cargo.toml | 15 | ||||
-rw-r--r-- | ipfs-cli/src/command/add.rs | 45 | ||||
-rw-r--r-- | ipfs-cli/src/command/bitswap.rs | 111 | ||||
-rw-r--r-- | ipfs-cli/src/command/block.rs | 92 | ||||
-rw-r--r-- | ipfs-cli/src/command/bootstrap.rs | 65 | ||||
-rw-r--r-- | ipfs-cli/src/command/cat.rs | 36 | ||||
-rw-r--r-- | ipfs-cli/src/command/commands.rs | 50 | ||||
-rw-r--r-- | ipfs-cli/src/command/config.rs | 51 | ||||
-rw-r--r-- | ipfs-cli/src/command/dag.rs | 48 | ||||
-rw-r--r-- | ipfs-cli/src/command/dht.rs | 104 | ||||
-rw-r--r-- | ipfs-cli/src/command/diag.rs | 81 | ||||
-rw-r--r-- | ipfs-cli/src/command/dns.rs | 40 | ||||
-rw-r--r-- | ipfs-cli/src/command/file.rs | 65 | ||||
-rw-r--r-- | ipfs-cli/src/command/files.rs | 186 | ||||
-rw-r--r-- | ipfs-cli/src/command/filestore.rs | 83 | ||||
-rw-r--r-- | ipfs-cli/src/command/mod.rs | 160 | ||||
-rw-r--r-- | ipfs-cli/src/command/shutdown.rs | 30 | ||||
-rw-r--r-- | ipfs-cli/src/command/version.rs | 38 | ||||
-rw-r--r-- | ipfs-cli/src/main.rs | 53 |
20 files changed, 1 insertions, 1355 deletions
@@ -1,6 +1,5 @@ [workspace] members = [ - "ipfs-api", - "ipfs-cli" + "ipfs-api" ] diff --git a/ipfs-cli/Cargo.toml b/ipfs-cli/Cargo.toml deleted file mode 100644 index e3e1343..0000000 --- a/ipfs-cli/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "ipfs-cli" -description = "A CLI to interact with IPFS" -authors = ["Ferris Tseng <ferristseng@fastmail.fm>"] -edition = "2018" -repository = "https://github.com/ferristseng/rust-ipfs-api" -version = "0.4.1" -readme = "../README.md" -license = "MIT OR Apache-2.0" - -[dependencies] -clap = "2.33" -futures = "0.3" -hyper = "0.13" -ipfs-api = { path = "../ipfs-api" } diff --git a/ipfs-cli/src/command/add.rs b/ipfs-cli/src/command/add.rs deleted file mode 100644 index 16411dd..0000000 --- a/ipfs-cli/src/command/add.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::{CliCommand, EXPECTED_FILE}; -use clap::App; -use futures::Future; -use std::path::Path; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "add"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand add => - (about: "Add file to IPFS") - (@arg INPUT: +required "File to add") - (@arg recursive: -r --recursive "Add directory paths recursively. Default: false") - ) - } - - handle!( - (args, client) => { - let path = args.value_of("INPUT").unwrap(); - if !args.is_present("recursive") && Path::new(path).is_dir() { - panic!(EXPECTED_FILE); - } - client - .add_path(path) - .map(|response| { - println!(); - println!(" name : {}", response.name); - println!(" hash : {}", response.hash); - println!(" size : {}", response.size); - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/bitswap.rs b/ipfs-cli/src/command/bitswap.rs deleted file mode 100644 index 5438d98..0000000 --- a/ipfs-cli/src/command/bitswap.rs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::Future; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "bitswap"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand bitswap => - (@setting SubcommandRequiredElseHelp) - (@subcommand ledger => - (about: "Show the current ledger for a peer") - (@arg PEER: +required "Peer to inspect") - ) - (@subcommand reprovide => - (about: "Triggers a reprovide") - ) - (@subcommand stat => - (about: "Show some diagnostic information on the bitswap agent") - ) - (@subcommand unwant => - (about: "Remove a given block from your wantlist") - (@arg KEY: +required "Key of the block to remove") - ) - (@subcommand wantlist => - (about: "Shows blocks currently on the wantlist") - ) - ) - } - - handle!( - client; - ("ledger", args) => { - let peer = args.value_of("PEER").unwrap(); - - client - .bitswap_ledger(peer) - .map(|ledger| { - println!(); - println!(" peer : {}", ledger.peer); - println!(" value : {}", ledger.value); - println!(" sent : {}", ledger.sent); - println!(" recv : {}", ledger.recv); - println!(" exchanged : {}", ledger.exchanged); - println!(); - }) - }, - ("reprovide", _args) => { - client.bitswap_reprovide().map(|_| ()) - }, - ("stat", _args) => { - client - .bitswap_stat() - .map(|stat| { - println!(); - println!(" provide_buf_len : {}", stat.provide_buf_len); - println!(" wantlist :"); - for want in stat.wantlist { - println!(" {}", want); - } - println!(" peers :"); - for peer in stat.peers { - println!(" {}", peer); - } - println!(" blocks_received : {}", stat.blocks_received); - println!(" data_received : {}", stat.data_received); - println!(" blocks_sent : {}", stat.blocks_sent); - println!(" data_sent : {}", stat.data_sent); - println!(" dup_blks_received : {}", stat.dup_blks_received); - println!(" dup_data_received : {}", stat.dup_data_received); - println!(); - }) - }, - ("unwant", args) => { - let key = args.value_of("KEY").unwrap(); - - client - .bitswap_unwant(key) - .map(|_| { - println!(); - println!(" OK"); - println!(); - }) - }, - ("wantlist", args) => { - let peer = args.value_of("PEER"); - - client - .bitswap_wantlist(peer) - .map(|wantlist| { - println!(); - println!(" wantlist :"); - for key in wantlist.keys { - println!(" {}", key); - } - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/block.rs b/ipfs-cli/src/command/block.rs deleted file mode 100644 index c477583..0000000 --- a/ipfs-cli/src/command/block.rs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::{verify_file, CliCommand, EXPECTED_FILE}; -use clap::App; -use futures::{Future, Stream}; -use std::fs::File; -use std::io::{self, Write}; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "block"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand block => - (@setting SubcommandRequiredElseHelp) - (@subcommand get => - (about: "Get a raw IPFS block") - (@arg KEY: +required "The base58 multihash of an existing block") - ) - (@subcommand put => - (about: "Store a file as an IPFS block") - (@arg INPUT: +required {verify_file} "The file to store as an IPFS block") - ) - (@subcommand rm => - (about: "Removes an IPFS block") - (@arg KEY: +required "The base58 multihash of a block to remove") - ) - (@subcommand stat => - (about: "Get information about a raw IPFS block") - (@arg KEY: +required "The base58 multihash of the block to retrieve") - ) - ) - } - - handle!( - client; - ("get", args) => { - let key = args.value_of("KEY").unwrap(); - - client - .block_get(key) - .for_each(|chunk| io::stdout().write_all(&chunk).map_err(From::from)) - }, - ("put", args) => { - let path = args.value_of("INPUT").unwrap(); - let file = File::open(path).expect(EXPECTED_FILE); - - client - .block_put(file) - .map(|block| { - println!(); - println!(" key : {}", block.key); - println!(" size : {}", block.size); - println!(); - }) - }, - ("rm", args) => { - let key = args.value_of("KEY").unwrap(); - - client - .block_rm(key) - .map(|rm| { - println!(); - println!(" hash : {}", rm.hash); - if let Some(error) = rm.error { - println!(" error : {}", error); - } - println!(); - }) - }, - ("stat", args) => { - let key = args.value_of("KEY").unwrap(); - - client - .block_stat(key) - .map(|stat| { - println!(); - println!(" key : {}", stat.key); - println!(" size : {}", stat.size); - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/bootstrap.rs b/ipfs-cli/src/command/bootstrap.rs deleted file mode 100644 index 550a8a1..0000000 --- a/ipfs-cli/src/command/bootstrap.rs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::Future; - -fn print_peers(peers: &[String]) { - println!(); - println!(" peers :"); - for peer in peers { - println!(" {}", peer); - } - println!(); -} - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "bootstrap"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand bootstrap => - (@setting SubcommandRequiredElseHelp) - (@subcommand add => - (@setting SubcommandRequiredElseHelp) - (@subcommand default => - (about: "Add default peers to the bootstrap list") - ) - ) - (@subcommand list => - (about: "Show peers in the bootstrap list") - ) - (@subcommand rm => - (@setting SubcommandRequiredElseHelp) - (@subcommand all => - (about: "Remove all peers from the bootstrap list") - ) - ) - ) - } - - handle!( - client; - ("add") => { - ("default", _args) => { - client.bootstrap_add_default().map(|peers| print_peers(&peers.peers)) - } - }, - ("list", _args) => { - client.bootstrap_list().map(|peers| print_peers(&peers.peers)) - }, - ("rm") => { - ("all", _args) => { - client.bootstrap_rm_all().map(|peers| print_peers(&peers.peers)) - } - } - ); -} diff --git a/ipfs-cli/src/command/cat.rs b/ipfs-cli/src/command/cat.rs deleted file mode 100644 index a04d661..0000000 --- a/ipfs-cli/src/command/cat.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::{Future, Stream}; -use std::io::{self, Write}; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "cat"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand cat => - (about: "Show IPFS object data") - (@arg PATH: +required "The path of the IPFS object to get") - ) - } - - handle!( - (args, client) => { - let path = args.value_of("PATH").unwrap(); - - client - .cat(&path) - .for_each(|chunk| io::stdout().write_all(&chunk).map_err(From::from)) - } - ); -} diff --git a/ipfs-cli/src/command/commands.rs b/ipfs-cli/src/command/commands.rs deleted file mode 100644 index 9092306..0000000 --- a/ipfs-cli/src/command/commands.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::Future; -use ipfs_api::response::CommandsResponse; - -fn recursive_print_commands(cmd: CommandsResponse, stack: &mut Vec<String>) { - if cmd.subcommands.is_empty() { - println!(" {} {}", stack.join(" "), cmd.name); - } else { - let (name, subcommands) = (cmd.name, cmd.subcommands); - - stack.push(name); - - for subcommand in subcommands { - recursive_print_commands(subcommand, stack); - } - - stack.pop(); - } -} - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "commands"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand commands => - (about: "List all available commands") - ) - } - - handle!( - (_args, client) => { - client.commands().map(|commands| { - println!(); - recursive_print_commands(commands, &mut Vec::new()); - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/config.rs b/ipfs-cli/src/command/config.rs deleted file mode 100644 index 03ea490..0000000 --- a/ipfs-cli/src/command/config.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::{verify_file, CliCommand, EXPECTED_FILE}; -use clap::App; -use futures::Future; -use std::fs::File; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "config"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand config => - (@setting SubcommandRequiredElseHelp) - (@subcommand edit => - (about: "Open the config file for editing") - ) - (@subcommand replace => - (about: "Replace the config file") - (@arg INPUT: +required {verify_file} "Config file to replace with") - ) - (@subcommand show => - (about: "Show the config file") - ) - ) - } - - handle!( - client; - ("edit", _args) => { - client.config_edit().map(|_| ()) - }, - ("replace", args) => { - let path = args.value_of("INPUT").unwrap(); - let config = File::open(path).expect(EXPECTED_FILE); - - client.config_replace(config).map(|_| ()) - }, - ("show", _args) => { - client.config_show().map(|config| println!("{}", config)) - } - ); -} diff --git a/ipfs-cli/src/command/dag.rs b/ipfs-cli/src/command/dag.rs deleted file mode 100644 index 529892f..0000000 --- a/ipfs-cli/src/command/dag.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::Future; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "dag"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand dag => - (@setting SubcommandRequiredElseHelp) - (@subcommand get => - (about: "Get a dag node from IPFS") - (@arg KEY: +required "The key of the object to get") - ) - ) - } - - handle!( - client; - ("get", args) => { - let key = args.value_of("KEY").unwrap(); - - client.dag_get(key).map(|dag| { - println!(); - if let Some(data) = dag.data { - println!(" data :"); - println!("{}", data); - } - println!(" links :"); - for link in dag.links { - println!(" {} ({}) ({:?})", link.name, link.size, link.cid); - } - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/dht.rs b/ipfs-cli/src/command/dht.rs deleted file mode 100644 index 72501cb..0000000 --- a/ipfs-cli/src/command/dht.rs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::{Future, Stream}; -use ipfs_api::response::DhtMessage; - -fn print_dht_response<E>(res: DhtMessage) -> Result<(), E> { - println!(); - println!(" id : {}", res.id); - println!(" type : {:?}", res.typ); - println!(" responses :"); - for peer_res in res.responses { - println!(" id : {}", peer_res.id); - println!(" addrs :"); - for addr in peer_res.addrs { - println!(" {}", addr); - } - println!(); - } - println!(" extra : {}", res.extra); - println!(); - - Ok(()) -} - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "dht"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand dht => - (@setting SubcommandRequiredElseHelp) - (@subcommand findpeer => - (about: "Query the DHT for all of the multiaddresses associated with a Peer ID") - (@arg PEER: +required "Peer to search for") - ) - (@subcommand findprovs => - (about: "Find peers in the DHT that can provide the given key") - (@arg KEY: +required "Key to search for") - ) - (@subcommand get => - (about: "Given a key, query the DHT for its best value") - (@arg KEY: +required "The key search for") - ) - (@subcommand provide => - (about: "Announce to the network that you are providing the given values") - (@arg KEY: +required "The key you are providing") - ) - (@subcommand put => - (about: "Write a key/value pair to the DHT") - (@arg KEY: +required "The key to store the value at") - (@arg VALUE: +required "The value to store") - ) - (@subcommand query => - (about: "Find the closest peer to a given peer by querying the DHT") - (@arg PEER: +required "The peer to run the query against") - ) - ) - } - - handle!( - client; - ("findpeer", args) => { - let peer = args.value_of("PEER").unwrap(); - - client.dht_findpeer(peer).for_each(print_dht_response) - }, - ("findprovs", args) => { - let key = args.value_of("KEY").unwrap(); - - client.dht_findprovs(key).for_each(print_dht_response) - }, - ("get", args) => { - let key = args.value_of("KEY").unwrap(); - - client.dht_get(key).for_each(print_dht_response) - }, - ("provide", args) => { - let key = args.value_of("KEY").unwrap(); - - client.dht_provide(&key).for_each(print_dht_response) - }, - ("put", args) => { - let key = args.value_of("KEY").unwrap(); - let val = args.value_of("VALUE").unwrap(); - - client.dht_put(key, val).for_each(print_dht_response) - }, - ("query", args) => { - let peer = args.value_of("PEER").unwrap(); - - client.dht_query(peer).for_each(print_dht_response) - } - ); -} diff --git a/ipfs-cli/src/command/diag.rs b/ipfs-cli/src/command/diag.rs deleted file mode 100644 index 4004441..0000000 --- a/ipfs-cli/src/command/diag.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::{App, Arg, SubCommand}; -use futures::Future; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "diag"; - - 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"), - ); - - clap_app!( - @subcommand diag => - (@setting SubcommandRequiredElseHelp) - (@subcommand cmds => - (@setting SubcommandRequiredElseHelp) - (@subcommand clear => - (about: "Clear inactive requests from the log") - ) - (subcommand: set_time_command) - ) - (@subcommand sys => - (about: "Print system diagnostic information") - ) - ) - } - - handle!( - client; - ("cmds") => { - ("clear", _args) => { - client - .diag_cmds_clear() - .map(|_| { - println!(""); - println!(" OK"); - println!(""); - }) - }, - ("set-time", args) => { - let time = args.value_of("TIME").unwrap(); - - client - .diag_cmds_set_time(&time) - .map(|_| { - println!(""); - println!(" OK"); - println!(""); - }) - } - }, - ("sys", _args) => { - client - .diag_sys() - .map(|sys| { - println!(); - println!(" {}", sys); - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/dns.rs b/ipfs-cli/src/command/dns.rs deleted file mode 100644 index ded4fe4..0000000 --- a/ipfs-cli/src/command/dns.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::Future; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "dns"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand dns => - (about: "Resolve a DNS link") - (@arg PATH: +required "The domain name to resolve") - (@arg recursive: -r --recursive "Resolve until the result is not a DNS link") - ) - } - - handle!( - (args, client) => { - let path = args.value_of("PATH").unwrap(); - - client - .dns(path, args.is_present("recursive")) - .map(|res| { - println!(); - println!(" path : {}", res.path); - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/file.rs b/ipfs-cli/src/command/file.rs deleted file mode 100644 index b663a69..0000000 --- a/ipfs-cli/src/command/file.rs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::CliCommand; -use clap::App; -use futures::Future; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "file"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand file => - (@setting SubcommandRequiredElseHelp) - (@subcommand ls => - (about: "List directory contents for Unix filesystem objects") - (@arg PATH: +required "The path to list links from") - ) - ) - } - - handle!( - client; - ("ls", args) => { - let path = args.value_of("PATH").unwrap(); - - client - .file_ls(path) - .map(|ls| { - println!(); - println!(" arguments :"); - for (k, arg) in ls.arguments { - println!(" arg : {}", k); - println!(" value : {}", arg); - println!(); - } - println!(" objects :"); - for (k, obj) in ls.objects { - println!(" key : {}", k); - println!(" hash : {}", obj.hash); - println!(" size : {}", obj.size); - println!(" type : {}", obj.typ); - println!(" links :"); - for link in obj.links { - println!(" name : {}", link.name); - println!(" hash : {}", link.hash); - println!(" size : {}", link.size); - if let Some(ref typ) = link.typ { - println!(" type : {}", typ); - } - println!(); - } - } - println!(); - }) - } - ); -} diff --git a/ipfs-cli/src/command/files.rs b/ipfs-cli/src/command/files.rs deleted file mode 100644 index 91142c4..0000000 --- a/ipfs-cli/src/command/files.rs +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2017 rust-ipfs-api Developers -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. -// - -use crate::command::{verify_file, CliCommand, EXPECTED_FILE}; -use clap::App; -use futures::{Future, Stream}; -use std::fs::File; -use std::io::{self, Write}; - -pub struct Command; - -impl CliCommand for Command { - const NAME: &'static str = "files"; - - fn signature<'a, 'b>() -> App<'a, 'b> { - clap_app!( - @subcommand files => - (@setting SubcommandRequiredElseHelp) - (@subcommand cp => - (about: "Copy files in MFS") - (@arg SRC: +required "The source object to copy") - |