diff options
Diffstat (limited to 'ipfs-cli/src/command/cat.rs')
-rw-r--r-- | ipfs-cli/src/command/cat.rs | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/ipfs-cli/src/command/cat.rs b/ipfs-cli/src/command/cat.rs index 1f77306..6e8a9e7 100644 --- a/ipfs-cli/src/command/cat.rs +++ b/ipfs-cli/src/command/cat.rs @@ -6,26 +6,31 @@ // copied, modified, or distributed except according to those terms. // -use clap::{App, ArgMatches}; -use command::EXPECTED_API; -use futures::stream::Stream; -use ipfs_api::IpfsClient; +use clap::App; +use command::CliCommand; +use futures::{Future, Stream}; use std::io::{self, Write}; -use tokio_core::reactor::Core; -pub 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") - ) -} +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") + ) + } -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)); + handle!( + (args, client) => { + let path = args.value_of("PATH").unwrap(); - core.run(req).expect(EXPECTED_API); + client + .cat(&path) + .for_each(|chunk| io::stdout().write_all(&chunk).map_err(From::from)) + } + ); } |