mirror of
https://github.com/denisidoro/navi
synced 2025-02-16 12:38:28 +00:00
Restart navi after adding a repo (#404)
This commit is contained in:
parent
52b5271217
commit
16e40ed128
2 changed files with 13 additions and 8 deletions
|
@ -53,7 +53,7 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> {
|
|||
let opts = FinderOpts {
|
||||
suggestion_type: SuggestionType::MultipleSelections,
|
||||
preview: Some(format!("cat '{}/{{}}'", tmp_path_str)),
|
||||
header: Some("Select the cheatsheets you want to import with <TAB> then hit <Enter>".to_string()),
|
||||
header: Some("Select the cheatsheets you want to import with <TAB> then hit <Enter>\nUse Ctrl-R for (de)selecting all".to_string()),
|
||||
preview_window: Some("right:30%".to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
|
@ -65,20 +65,21 @@ pub fn add(uri: String, finder: &FinderChoice) -> Result<(), Error> {
|
|||
})
|
||||
.context("Failed to get cheatsheet files from finder")?;
|
||||
|
||||
let to_folder = format!("{}/{}__{}", cheat_path_str, user, repo).replace("./", "");
|
||||
|
||||
for f in files.split('\n') {
|
||||
let from = format!("{}/{}", tmp_path_str, f).replace("./", "");
|
||||
let to_folder = format!("{}/{}__{}", cheat_path_str, user, repo).replace("./", "");
|
||||
let filename = f.replace("./", "").replace("/", "__");
|
||||
let to = format!("{}/{}", to_folder, filename);
|
||||
fs::create_dir_all(to_folder).unwrap_or(());
|
||||
let to = format!("{}/{}", &to_folder, filename);
|
||||
fs::create_dir_all(&to_folder).unwrap_or(());
|
||||
fs::copy(&from, &to).with_context(|| format!("Failed to copy `{}` to `{}`", from, to))?;
|
||||
}
|
||||
|
||||
filesystem::remove_dir(&tmp_path_str)?;
|
||||
|
||||
eprintln!(
|
||||
"The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}\n\nPlease run navi again to check the results.",
|
||||
files, cheat_path_str
|
||||
"The following .cheat files were imported successfully:\n{}\n\nThey are now located at {}/{}",
|
||||
files, cheat_path_str, to_folder
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -19,9 +19,13 @@ pub fn handle_config(config: Config) -> Result<(), Error> {
|
|||
|
||||
Repo { cmd } => match cmd {
|
||||
RepoCommand::Add { uri } => {
|
||||
cmds::repo::add(uri.clone(), &config.finder).with_context(|| format!("Failed to import cheatsheets from `{}`", uri))
|
||||
cmds::repo::add(uri.clone(), &config.finder).with_context(|| format!("Failed to import cheatsheets from `{}`", uri))?;
|
||||
cmds::core::main(config)
|
||||
}
|
||||
RepoCommand::Browse => {
|
||||
cmds::repo::browse(&config.finder).context("Failed to browse featured cheatsheets")?;
|
||||
cmds::core::main(config)
|
||||
}
|
||||
RepoCommand::Browse => cmds::repo::browse(&config.finder).context("Failed to browse featured cheatsheets"),
|
||||
},
|
||||
|
||||
Alfred { cmd } => match cmd {
|
||||
|
|
Loading…
Add table
Reference in a new issue