2020-03-05 13:09:32 +00:00
|
|
|
mod db;
|
|
|
|
|
mod dir;
|
2020-03-13 00:49:37 +00:00
|
|
|
mod subcommand;
|
2020-03-05 13:09:32 +00:00
|
|
|
mod types;
|
|
|
|
|
mod util;
|
|
|
|
|
|
2020-03-13 00:49:37 +00:00
|
|
|
use anyhow::Result;
|
2020-03-10 18:32:40 +00:00
|
|
|
use structopt::StructOpt;
|
|
|
|
|
|
|
|
|
|
// TODO: use structopt to parse env variables: <https://github.com/TeXitoi/structopt/blob/master/examples/env.rs>
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
|
#[structopt(about = "A cd command that learns your habits")]
|
|
|
|
|
enum Zoxide {
|
2020-03-13 00:49:37 +00:00
|
|
|
Add(subcommand::Add),
|
|
|
|
|
Init(subcommand::Init),
|
|
|
|
|
Migrate(subcommand::Migrate),
|
|
|
|
|
Query(subcommand::Query),
|
|
|
|
|
Remove(subcommand::Remove),
|
2020-03-05 13:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-10 18:32:40 +00:00
|
|
|
pub fn main() -> Result<()> {
|
|
|
|
|
let opt = Zoxide::from_args();
|
|
|
|
|
match opt {
|
2020-03-13 00:49:37 +00:00
|
|
|
Zoxide::Add(add) => add.run()?,
|
2020-03-13 01:39:21 +00:00
|
|
|
Zoxide::Init(init) => init.run(),
|
2020-03-13 00:49:37 +00:00
|
|
|
Zoxide::Migrate(migrate) => migrate.run()?,
|
|
|
|
|
Zoxide::Query(query) => query.run()?,
|
|
|
|
|
Zoxide::Remove(remove) => remove.run()?,
|
2020-03-10 18:32:40 +00:00
|
|
|
};
|
2020-03-06 17:43:32 +00:00
|
|
|
|
2020-03-10 18:32:40 +00:00
|
|
|
Ok(())
|
|
|
|
|
}
|