zinit icon indicating copy to clipboard operation
zinit copied to clipboard

feat: Add %SYMBOL% substituting to non-clone time ices like atinit'', atload'', etc.

Open psprint opened this issue 3 years ago • 10 comments

Description

There are many such symbol var-like symbols:

  • %ID% – id-as ice
  • %USER% – username (in user/plugin ID)
  • %PLUGIN% – plugin name (in user/plugin ID)
  • %URL% – snippet url
  • %DIR% – plugin directory path
  • %ZPFX% – value of $ZPFX
  • %OS% – $OSTYPE
  • %MACH% – $MACHTYPE
  • %CPU% – $CPUTYPE
  • %VENDOR% – $VENDOR
  • %HOST% – $HOST
  • %UID% – $UID (numerical user id)
  • %GID% – $GID (group #)

With this patch many has been fixed (like %ID%, %USER%, %PLUGIN% were returning empty strings, possibly breaking packages, where this undocumented feature is used) and support for load-time ices (like atload'', etc.) have been added.

Motivation and Context

I wanted to make %SYM% more widely used, it might yield interesting use cases. Maybe some new vars can be added? README is updated to mntion the feature.

Related Issue(s)

Usage examples

For example:

zinit id-as'plugin-%UID%' atload'print Loaded from dir: %DIR%, plugin id: %ID%' for zd

output is:

Loaded from dir: /home/q/.local/share/zinit/plugins/plugin-500, plugin id: plugin-500

How Has This Been Tested?

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.

psprint avatar Dec 29 '22 17:12 psprint

@psprint The commit fails on the linter

https://github.com/zdharma-continuum/zinit/actions/runs/3802251129/jobs/6467549407#step:6:10

vladdoster avatar Dec 31 '22 03:12 vladdoster

It should now pass the linter.

psprint avatar Feb 15 '23 16:02 psprint

The commit message should be all lowercase.

vladdoster avatar Feb 16 '23 05:02 vladdoster

The commit message should be all lowercase.

@vladdoster: fixed

psprint avatar Feb 16 '23 10:02 psprint

@vladdoster I don't know why README.md isn't formatted, could you help?

psprint avatar Feb 16 '23 11:02 psprint

@psprint,

What is an actual use case for this?

vladdoster avatar Apr 29 '23 04:04 vladdoster

It's an ability to include special var-like strings like '%USER%' or '%PLUGIN%' etc. In atload'',atinit'', etc. ices and not only in atclone'' etc. ices

sob., 29 kwi 2023, 06:26 użytkownik vladislav doster < @.***> napisał:

@psprint https://github.com/psprint,

What is an actual use case for this?

— Reply to this email directly, view it on GitHub https://github.com/zdharma-continuum/zinit/pull/450#issuecomment-1528647502, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOE4CGI6TNMNH4MXX436MDXDSKA5ANCNFSM6AAAAAATMI77DU . You are receiving this because you were mentioned.Message ID: @.***>

psprint avatar Apr 29 '23 11:04 psprint

@vladdoster Oh, I see that I've already described the feature in PR message. As for the use case, it's: e.g.: ability to just write my-%PLUGIN% in id-as'' ice to obtain e.g.: my-dstask, i.e.:

zinit id-as'my-%PLUGIN%' from"gh-r" sbin'*->dstask' bpick'^*import*' \
        for @naggie/dstask

I think that such special vars are useful and needed from the point of view of versatility, to provide a complete support of the intentions of users (one could want such automatic plugin-name reference, for example).

psprint avatar Apr 29 '23 18:04 psprint

@vladdoster: I've fixed the markdown in README.md (was exceeding 120 chars line lenght)

psprint avatar Apr 29 '23 19:04 psprint

@vladdoste: Eh, mdformat is stil failing, I think that I'll give up, as I've run it without --check and then committed the result… Could you look?

psprint avatar Apr 29 '23 19:04 psprint