mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-11-17 10:35:12 +00:00
Rename migrate
command to import
This commit is contained in:
parent
76dfaad9a1
commit
5547fb4b80
@ -60,10 +60,10 @@ If you want the interactive fuzzy selection feature, you will also need to insta
|
|||||||
|
|
||||||
### Step 2: Adding `zoxide` to your shell
|
### Step 2: Adding `zoxide` to your shell
|
||||||
|
|
||||||
If you currently use `z`, `z.lua`, or `zsh-z`, you may want to first migrate your existing database to `zoxide`:
|
If you currently use `z`, `z.lua`, or `zsh-z`, you may want to first import your existing database into `zoxide`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
zoxide migrate /path/to/db
|
zoxide import /path/to/db
|
||||||
```
|
```
|
||||||
|
|
||||||
#### zsh
|
#### zsh
|
||||||
|
@ -54,10 +54,10 @@ impl DB {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn migrate<P: AsRef<Path>>(&mut self, path: P, merge: bool) -> Result<()> {
|
pub fn import<P: AsRef<Path>>(&mut self, path: P, merge: bool) -> Result<()> {
|
||||||
if !self.dirs.is_empty() && !merge {
|
if !self.dirs.is_empty() && !merge {
|
||||||
bail!(indoc!(
|
bail!(indoc!(
|
||||||
"To prevent conflicts, you can only migrate from z with an empty zoxide database!
|
"To prevent conflicts, you can only import from z with an empty zoxide database!
|
||||||
If you wish to merge the two, specify the `--merge` flag."
|
If you wish to merge the two, specify the `--merge` flag."
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ use structopt::StructOpt;
|
|||||||
#[structopt(about = "A cd command that learns your habits")]
|
#[structopt(about = "A cd command that learns your habits")]
|
||||||
enum Zoxide {
|
enum Zoxide {
|
||||||
Add(subcommand::Add),
|
Add(subcommand::Add),
|
||||||
|
Import(subcommand::Import),
|
||||||
Init(subcommand::Init),
|
Init(subcommand::Init),
|
||||||
Migrate(subcommand::Migrate),
|
|
||||||
Query(subcommand::Query),
|
Query(subcommand::Query),
|
||||||
Remove(subcommand::Remove),
|
Remove(subcommand::Remove),
|
||||||
}
|
}
|
||||||
@ -28,8 +28,8 @@ pub fn main() -> Result<()> {
|
|||||||
|
|
||||||
match opt {
|
match opt {
|
||||||
Zoxide::Add(add) => add.run(&env)?,
|
Zoxide::Add(add) => add.run(&env)?,
|
||||||
|
Zoxide::Import(import) => import.run(&env)?,
|
||||||
Zoxide::Init(init) => init.run()?,
|
Zoxide::Init(init) => init.run()?,
|
||||||
Zoxide::Migrate(migrate) => migrate.run(&env)?,
|
|
||||||
Zoxide::Query(query) => query.run(&env)?,
|
Zoxide::Query(query) => query.run(&env)?,
|
||||||
Zoxide::Remove(remove) => remove.run(&env)?,
|
Zoxide::Remove(remove) => remove.run(&env)?,
|
||||||
};
|
};
|
||||||
|
@ -5,16 +5,16 @@ use anyhow::Result;
|
|||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
#[structopt(about = "Migrate from z database")]
|
#[structopt(about = "Import from z database")]
|
||||||
pub struct Migrate {
|
pub struct Import {
|
||||||
path: String,
|
path: String,
|
||||||
|
|
||||||
#[structopt(long, help = "Merge entries into existing database")]
|
#[structopt(long, help = "Merge entries into existing database")]
|
||||||
merge: bool,
|
merge: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Migrate {
|
impl Import {
|
||||||
pub fn run(&self, env: &Env) -> Result<()> {
|
pub fn run(&self, env: &Env) -> Result<()> {
|
||||||
util::get_db(env)?.migrate(&self.path, self.merge)
|
util::get_db(env)?.import(&self.path, self.merge)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
mod add;
|
mod add;
|
||||||
|
mod import;
|
||||||
mod init;
|
mod init;
|
||||||
mod migrate;
|
|
||||||
mod query;
|
mod query;
|
||||||
mod remove;
|
mod remove;
|
||||||
|
|
||||||
pub use add::Add;
|
pub use add::Add;
|
||||||
|
pub use import::Import;
|
||||||
pub use init::Init;
|
pub use init::Init;
|
||||||
pub use migrate::Migrate;
|
|
||||||
pub use query::Query;
|
pub use query::Query;
|
||||||
pub use remove::Remove;
|
pub use remove::Remove;
|
||||||
|
Loading…
Reference in New Issue
Block a user