feat: add clone spinner
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Kasper Juul Hermansen 2024-09-23 19:45:23 +02:00
parent 866a8b4c52
commit c9aacf0ecd
Signed by: kjuulh
SSH Key Fingerprint: SHA256:RjXh0p7U6opxnfd3ga/Y9TCo18FYlHFdSpRIV72S/QM
7 changed files with 31 additions and 15 deletions

View File

@ -1 +1,2 @@
pub mod root; pub mod root;
pub mod shell;

View File

@ -29,23 +29,33 @@ impl RootCommand {
clone: bool, clone: bool,
shell: bool, shell: bool,
force_refresh: bool, force_refresh: bool,
force_cache_update: bool,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
tracing::debug!("executing"); tracing::debug!("executing");
let repositories = if cache { let repositories = if !force_cache_update {
match self.app.cache().get().await? { if cache {
Some(repos) => repos, match self.app.cache().get().await? {
None => { Some(repos) => repos,
tracing::info!("finding repositories..."); None => {
let repositories = self.app.projects_list().get_projects().await?; 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 { } 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 { let repo = match search {

View File

View File

@ -75,12 +75,6 @@ impl SpinnerState {
if now.duration_since(self.last_event) >= self.interval { if now.duration_since(self.last_event) >= self.interval {
self.last_event = now; self.last_event = now;
self.next_state(); self.next_state();
batch.with(Command::new(|d| {
d.send(Msg::Tick);
None
}));
} }
batch batch

View File

@ -43,6 +43,9 @@ struct Command {
#[arg(long = "force-refresh", default_value = "false")] #[arg(long = "force-refresh", default_value = "false")]
force_refresh: bool, force_refresh: bool,
#[arg(long = "force-cache-update", default_value = "false")]
force_cache_update: bool,
} }
#[derive(Subcommand)] #[derive(Subcommand)]
@ -87,6 +90,7 @@ async fn main() -> anyhow::Result<()> {
!cli.no_clone, !cli.no_clone,
!cli.no_shell, !cli.no_shell,
cli.force_refresh, cli.force_refresh,
cli.force_cache_update,
) )
.await?; .await?;
} }

View File

@ -21,3 +21,5 @@ scripts:
type: shell type: shell
update-gifs: update-gifs:
type: shell type: shell
install:
type: shell

5
scripts/install.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env zsh
set -e
cargo install --path crates/gitnow