diff --git a/crates/gitnow/src/commands.rs b/crates/gitnow/src/commands.rs index dec16f3..30cd74e 100644 --- a/crates/gitnow/src/commands.rs +++ b/crates/gitnow/src/commands.rs @@ -1 +1,2 @@ pub mod root; +pub mod shell; diff --git a/crates/gitnow/src/commands/root.rs b/crates/gitnow/src/commands/root.rs index 4b2ae50..c39c844 100644 --- a/crates/gitnow/src/commands/root.rs +++ b/crates/gitnow/src/commands/root.rs @@ -29,23 +29,33 @@ impl RootCommand { clone: bool, shell: bool, force_refresh: bool, + force_cache_update: bool, ) -> anyhow::Result<()> { tracing::debug!("executing"); - let repositories = if cache { - match self.app.cache().get().await? { - Some(repos) => repos, - None => { - tracing::info!("finding repositories..."); - let repositories = self.app.projects_list().get_projects().await?; + let repositories = if !force_cache_update { + if cache { + match self.app.cache().get().await? { + Some(repos) => repos, + None => { + tracing::info!("finding repositories..."); + let repositories = self.app.projects_list().get_projects().await?; - self.app.cache().update(&repositories).await?; + self.app.cache().update(&repositories).await?; - repositories + repositories + } } + } else { + self.app.projects_list().get_projects().await? } } else { - self.app.projects_list().get_projects().await? + tracing::info!("forcing cache update..."); + let repositories = self.app.projects_list().get_projects().await?; + + self.app.cache().update(&repositories).await?; + + repositories }; let repo = match search { diff --git a/crates/gitnow/src/commands/shell.rs b/crates/gitnow/src/commands/shell.rs new file mode 100644 index 0000000..e69de29 diff --git a/crates/gitnow/src/components/spinner.rs b/crates/gitnow/src/components/spinner.rs index 48d577c..8827475 100644 --- a/crates/gitnow/src/components/spinner.rs +++ b/crates/gitnow/src/components/spinner.rs @@ -75,12 +75,6 @@ impl SpinnerState { if now.duration_since(self.last_event) >= self.interval { self.last_event = now; self.next_state(); - - batch.with(Command::new(|d| { - d.send(Msg::Tick); - - None - })); } batch diff --git a/crates/gitnow/src/main.rs b/crates/gitnow/src/main.rs index 52f0bcc..3e838b3 100644 --- a/crates/gitnow/src/main.rs +++ b/crates/gitnow/src/main.rs @@ -43,6 +43,9 @@ struct Command { #[arg(long = "force-refresh", default_value = "false")] force_refresh: bool, + + #[arg(long = "force-cache-update", default_value = "false")] + force_cache_update: bool, } #[derive(Subcommand)] @@ -87,6 +90,7 @@ async fn main() -> anyhow::Result<()> { !cli.no_clone, !cli.no_shell, cli.force_refresh, + cli.force_cache_update, ) .await?; } diff --git a/cuddle.yaml b/cuddle.yaml index 68e0033..ebcec99 100644 --- a/cuddle.yaml +++ b/cuddle.yaml @@ -21,3 +21,5 @@ scripts: type: shell update-gifs: type: shell + install: + type: shell diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..ea608f2 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env zsh + +set -e + +cargo install --path crates/gitnow