hacker_news/cli/
mod.rs

1use std::error::Error;
2use clap::App;
3use clap::ArgMatches;
4
5pub(crate) mod login;
6pub(crate) mod news;
7pub(crate) mod query;
8pub(crate) mod thread;
9pub(crate) mod tree;
10pub mod hacker_news;
11
12/// A trait defining the interface to add a subcommand to the command line
13/// application. 
14pub trait HnCommand {
15
16    /// The name of this subcommand. Will be used at the command line interface
17    /// to name this subcommand.
18    const NAME: &'static str;
19
20    /// A function which returns a [clap](https://docs.rs/clap/2.33.3/clap/index.html)
21    /// App instance. This App will be used as a subcommand in the over all command line
22    /// application structure.
23    fn parser<'a, 'b>() -> App<'a, 'b>;
24
25    /// The command executed when this subcommand is actually run. This function receives a
26    /// [clap](https://docs.rs/clap/2.33.3/clap/index.html) ArgMatches instance, which can
27    /// drive optional or argument based logic.
28    fn cmd(matches: &ArgMatches) -> Result<(), Box<dyn Error>>;
29}