z-shell / zi

✨ A Swiss Army Knife for Zsh - Unix Shell
https://wiki.zshell.dev
MIT License
735 stars 42 forks source link

[feat]: doOnce with retry #289

Open xenoterracide opened 11 months ago

xenoterracide commented 11 months ago

Feature description

if a portion of an ice command fails

Related Code

so I have this code, as an example

  zi ice lucid wait \
    cloneonly nocompile notify \
    atclone"install --compare -D after/syntax/zsh.vim $VIM_AFTER_SYNTAX/zsh.vim" \
    atpull"%atclone"
  zi light z-shell/zinit-vim-syntax

the problem is that this requires GNU install. Now I can test for that in various ways, and have actually updated my code to do so in a mac environment. Before this though I just ran this code and it would work if brew (or something) had already put it on the PATH. I'd always run this code, but after an initial setup of ZI if gnu install wasn't there at a shell launch I'd have to blow away ~/.zi and run this again. I don't want to run this every time I load the shell so doing atload is out of the question. Instead what I've done is duplicated this code and checked for gnu install.

  zi ice lucid wait'[[ -f $(brew --prefix coreutils)/libexec/gnubin/install ]]' \
    cloneonly nocompile notify \
    atclone"install --compare -D after/syntax/zsh.vim $VIM_AFTER_SYNTAX/zsh.vim" \
    atpull"%atclone"
  zi light z-shell/zinit-vim-syntax

while this works for this case I'd much rather simply retry the operation on a subsequent run if it didn't work this time.

As a continuation use case

zi ice lucid wait has'asdf' atclone'asdf plugin add nodejs' for z-shell/null

doesn't seem to work I expect this is because of how the atClone cycle works

I think these could be better done like this

zi ice lucid wait retry doonce'install --compare -D after/syntax/zsh.vim $VIM_AFTER_SYNTAX/zsh.vim'
zi ice lucid wait retry has'asdf' doonce'asdf plugin add nodejs'

I would not have has returning false mark the doonce as done.

Additional Context

No response

Self-service

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

xenoterracide@gmail.com

github-actions[bot] commented 10 months ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!