mirror of
https://github.com/denisidoro/navi.git
synced 2026-01-23 02:14:19 +00:00
feat: Add -a/--all for repo commands to skip confirmation
Using `-a` will skip the "Do you want to import all files from this repo?" check and assume yes, since I found out that the `yes` tool doesn't work for this somehow? Also aliased to `-y/--yes`.
This commit is contained in:
parent
b01291e040
commit
f30475a990
2 changed files with 14 additions and 7 deletions
|
|
@ -25,10 +25,10 @@ fn ask_if_should_import_all(finder: &FinderChoice) -> Result<bool> {
|
|||
Ok(response.to_lowercase().starts_with('y'))
|
||||
}
|
||||
|
||||
pub fn main(uri: String) -> Result<()> {
|
||||
pub fn main(uri: String, import_all: bool) -> Result<()> {
|
||||
let finder = CONFIG.finder();
|
||||
|
||||
let should_import_all = ask_if_should_import_all(&finder).unwrap_or(false);
|
||||
let should_import_all = import_all || ask_if_should_import_all(&finder).unwrap_or(false);
|
||||
let (actual_uri, user, repo) = git::meta(uri.as_str());
|
||||
|
||||
let cheat_pathbuf = filesystem::default_cheat_pathbuf()?;
|
||||
|
|
|
|||
|
|
@ -11,9 +11,16 @@ pub enum RepoCommand {
|
|||
Add {
|
||||
/// A URI to a git repository containing .cheat files ("user/repo" will download cheats from github.com/user/repo)
|
||||
uri: String,
|
||||
/// Import all cheatsheets from repo without prompting
|
||||
#[clap(short = 'a', long, visible_short_alias = 'y', visible_alias = "yes")]
|
||||
all: bool,
|
||||
},
|
||||
/// Browses for featured cheatsheet repos
|
||||
Browse,
|
||||
Browse {
|
||||
/// Import all cheatsheets from selected repo without prompting
|
||||
#[clap(short = 'a', long, visible_short_alias = 'y', visible_alias = "yes")]
|
||||
all: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Args)]
|
||||
|
|
@ -25,14 +32,14 @@ pub struct Input {
|
|||
impl Runnable for Input {
|
||||
fn run(&self) -> Result<()> {
|
||||
match &self.cmd {
|
||||
RepoCommand::Add { uri } => {
|
||||
add::main(uri.clone())
|
||||
RepoCommand::Add { uri, all } => {
|
||||
add::main(uri.clone(), *all)
|
||||
.with_context(|| format!("Failed to import cheatsheets from `{uri}`"))?;
|
||||
commands::core::main()
|
||||
}
|
||||
RepoCommand::Browse => {
|
||||
RepoCommand::Browse { all } => {
|
||||
let repo = browse::main().context("Failed to browse featured cheatsheets")?;
|
||||
add::main(repo.clone())
|
||||
add::main(repo.clone(), *all)
|
||||
.with_context(|| format!("Failed to import cheatsheets from `{repo}`"))?;
|
||||
commands::core::main()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue