Julio Biason
3 years ago
4 changed files with 114 additions and 9 deletions
@ -0,0 +1,43 @@
|
||||
/* |
||||
DOWNFAV - Download Favourites |
||||
Copyright (C) 2020 Julio Biason |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU Affero General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU Affero General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU Affero General Public License |
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
use clap::App; |
||||
use clap::SubCommand; |
||||
|
||||
/// Possible commands
|
||||
pub enum Command { |
||||
/// Got a command that we don't know
|
||||
Unknown, |
||||
/// Fetch all new favourites
|
||||
Fetch, |
||||
} |
||||
|
||||
/// Parse the command line, returning the necessary command.
|
||||
pub fn parse() -> Command { |
||||
let parser = App::new(clap::crate_name!()) |
||||
.version(clap::crate_version!()) |
||||
.author(clap::crate_authors!()) |
||||
.about(clap::crate_description!()) |
||||
.subcommand(SubCommand::with_name("fetch").about("Fetch the new favourites")); |
||||
let matches = parser.get_matches(); |
||||
match matches.subcommand() { |
||||
("", _) => Command::Fetch, |
||||
("fetch", _) => Command::Fetch, |
||||
_ => Command::Unknown, |
||||
} |
||||
} |
Loading…
Reference in new issue