mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-03 09:39:15 +02:00
Extract CLI logic to a child project
This commit is contained in:
parent
2df0f8d077
commit
7a56dabd39
11 changed files with 26 additions and 23 deletions
|
@ -1,35 +0,0 @@
|
|||
use super::clap::{App, ArgMatches};
|
||||
|
||||
use app::*;
|
||||
|
||||
use super::cmd_upload::CmdUpload;
|
||||
|
||||
/// CLI argument handler.
|
||||
pub struct Handler<'a> {
|
||||
/// The CLI matches.
|
||||
matches: ArgMatches<'a>,
|
||||
}
|
||||
|
||||
impl<'a: 'b, 'b> Handler<'a> {
|
||||
/// Build the application CLI definition.
|
||||
pub fn build() -> App<'a, 'b> {
|
||||
App::new(APP_NAME)
|
||||
.version(APP_VERSION)
|
||||
.author(APP_AUTHOR)
|
||||
.about(APP_ABOUT)
|
||||
.subcommand(CmdUpload::build().display_order(1))
|
||||
}
|
||||
|
||||
/// Parse CLI arguments.
|
||||
pub fn parse() -> Handler<'a> {
|
||||
// Build the application CLI definition, get the matches
|
||||
Handler {
|
||||
matches: Handler::build().get_matches(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the upload sub command, if matched.
|
||||
pub fn upload(&'a self) -> Option<CmdUpload<'a>> {
|
||||
CmdUpload::parse(&self.matches)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue