add tldr and base
This commit is contained in:
16
src/main.rs
Normal file
16
src/main.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use prereqs::prereqs_exec;
|
||||
use util::Cmd;
|
||||
|
||||
mod prereqs;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
let matches = clap::Command::new("toolkit")
|
||||
.subcommands([prereqs::prereqs()?, tldr::Tldr::cmd()?])
|
||||
.get_matches();
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("prereqs", subcmd)) => prereqs_exec(subcmd),
|
||||
Some(("tldr", subcmd)) => tldr::Tldr::exec(subcmd),
|
||||
_ => Err(eyre::anyhow!("no command selected!")),
|
||||
}
|
||||
}
|
37
src/prereqs.rs
Normal file
37
src/prereqs.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use clap::ArgMatches;
|
||||
|
||||
const DEPS: &[&str] = &["gh", "fzf"];
|
||||
|
||||
// -- List
|
||||
//
|
||||
|
||||
pub fn ls() -> clap::Command {
|
||||
clap::Command::new("ls")
|
||||
}
|
||||
|
||||
pub fn ls_exec() -> eyre::Result<()> {
|
||||
println!("Required packages\n---");
|
||||
|
||||
let mut deps: Vec<&str> = DEPS.into_iter().map(|d| d.clone()).collect();
|
||||
deps.sort();
|
||||
for dep in deps {
|
||||
println!("{}", dep)
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// -- Prereqs
|
||||
//
|
||||
|
||||
pub fn prereqs() -> eyre::Result<clap::Command> {
|
||||
let cmd = clap::Command::new("prereqs").subcommands([ls()]);
|
||||
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
pub fn prereqs_exec(matches: &ArgMatches) -> eyre::Result<()> {
|
||||
match matches.subcommand() {
|
||||
Some(("ls", _)) => ls_exec(),
|
||||
_ => Err(eyre::anyhow!("not implemented")),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user