Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make new zsh completion #132 #266

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

Turiok
Copy link
Contributor

@Turiok Turiok commented Nov 2, 2023

Hello everyone,

I have succeeded with the old zsh completion.
Adding in my .zshrc

autoload -U +X bashcompinit && bashcompinit
source /path/to/your/gita_completion_script

But the completion is not Zsh style and seems very limited.

I propose a new zsh completion.
It's my second completion zsh script. So be nice and give me pointers if I'm wrong.

I find the completion nicer and dynamic depending your configuration. By exemple, it display your repositories or your groups.

To me, it miss 2 things :

  • Completion for color command gita color set <TAB> displaying the possible colors.
  • For the gita group add command. I don't know if options -n and -p are exclusive? Easy to correct. I just have to know

Other problem. If the community doesn't know zsh completion. It is probably complex to maintain.
Maybe, I'll propose this completion to other repository like https://github.com/zsh-users/zsh-completions if @nosarthur doesn't want this PR.

@nosarthur
Copy link
Owner

Thanks for the contribution. Maybe add a folder and place both completion script there so people can choose?

@Turiok Turiok force-pushed the bugfix/#132_completions_zsh branch from e544383 to d109b6d Compare November 3, 2023 07:34
@Turiok
Copy link
Contributor Author

Turiok commented Nov 3, 2023

Do you want I move the bash completion version in bash folder?

@Turiok Turiok marked this pull request as draft November 3, 2023 08:02
Copy link

codecov bot commented Nov 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a5ba6fe) 86.25% compared to head (d109b6d) 86.38%.

❗ Current head d109b6d differs from pull request most recent head 6791680. Consider uploading reports for the commit 6791680 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #266      +/-   ##
==========================================
+ Coverage   86.25%   86.38%   +0.12%     
==========================================
  Files           5        5              
  Lines         793      793              
==========================================
+ Hits          684      685       +1     
+ Misses        109      108       -1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nosarthur
Copy link
Owner

sure, thanks

One minor suggestion: the folder structure can be simplified to auto-completion/zsh/... and auto-completion/bash/...

@Turiok
Copy link
Contributor Author

Turiok commented Nov 6, 2023

OK to change the folder. I made that in case you have other contribution for other people.

@Turiok Turiok force-pushed the bugfix/#132_completions_zsh branch from d109b6d to ca7a3fa Compare November 6, 2023 09:17
@Turiok Turiok marked this pull request as ready for review November 6, 2023 09:17
README.md Outdated Show resolved Hide resolved
@@ -780,17 +780,18 @@ def main(argv=None):
cmds = utils.get_cmds_from_files()
for name, data in cmds.items():
help = data.get("help")
repo_help = help
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why split help into two?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the same help than before, I think the general help is too loaded.
But I can go back

Before The general help : gita -h
sub-commands:
  {add,rm,freeze,clone,rename,flags,color,info,ll,context,ls,group,super,shell,clear,br,clean,diff,difftool,fetch,last,lo,log,merge,mergetool,patch,pull,push,rebase,reflog,remote,reset,show,stash,stat,st,tag}
                        additional help with sub-command -h
    add                 add repo(s)
    rm                  remove repo(s)
    freeze              print all repo information
    clone               clone repos
    rename              rename a repo
    flags               git flags configuration
    color               color configuration
    info                information setting
    ll                  display summary of all repos
    context             set context
    ls                  show repo(s) or repo path
    group               group repos
    super               run any git command/alias
    shell               run any shell command
    clear               removes all groups and repositories
    br                  show local branches for the chosen repo(s) or group(s)
    clean               remove all untracked files/folders for the chosen repo(s) or group(s)
    diff                git show differences for the chosen repo(s) or group(s)
    difftool            show differences using a tool for the chosen repo(s) or group(s)
    fetch               fetch remote update for all repos or for the chosen repo(s) or group(s)
    last                show log information of HEAD for the chosen repo(s) or group(s)
    lo                  show one-line log for the latest 7 commits for all repos or for the chosen repo(s) or group(s)
    log                 show logs for the chosen repo(s) or group(s)
    merge               merge remote updates for the chosen repo(s) or group(s)
    mergetool           merge updates with a tool for the chosen repo(s) or group(s)
    patch               make a patch for the chosen repo(s) or group(s)
    pull                pull remote updates for all repos or for the chosen repo(s) or group(s)
    push                push the local updates for all repos or for the chosen repo(s) or group(s)
    rebase              rebase from master for the chosen repo(s) or group(s)
    reflog              show ref logs for the chosen repo(s) or group(s)
    remote              show remote settings for the chosen repo(s) or group(s)
    reset               reset repo(s) for the chosen repo(s) or group(s)
    show                show detailed commit information for the chosen repo(s) or group(s)
    stash               store uncommited changes for the chosen repo(s) or group(s)
    stat                show edit statistics for all repos or for the chosen repo(s) or group(s)
    st                  show status for all repos or for the chosen repo(s) or group(s)
    tag                 show tags for the chosen repo(s) or group(s)

a specific help :
gita st -h :

usage: gita st [-h] [-s SHELL] [{gita,artifactory-cleanup,arch-mu-repo,stackedit-docker,gitlab-branch-source-plugin,analyse_bonnes_pratiques,ul_cnes,open_source,} ...]

show status for all repos or for the chosen repo(s) or group(s)

positional arguments:
  {gita,artifactory-cleanup,arch-mu-repo,stackedit-docker,gitlab-branch-source-plugin,analyse_bonnes_pratiques,ul_cnes,open_source,[]}
                        show status for all repos or for the chosen repo(s) or group(s)

options:
  -h, --help            show this help message and exit
  -s SHELL, --shell SHELL
                        If set, run in shell mode

with my version :

After general help : gita -h
sub-commands:
  {add,rm,freeze,clone,rename,flags,color,info,ll,context,ls,group,super,shell,clear,br,clean,diff,difftool,fetch,last,lo,log,merge,mergetool,patch,pull,push,rebase,reflog,remote,reset,show,stash,stat,st,tag}
                        additional help with sub-command -h
    add                 add repo(s)
    rm                  remove repo(s)
    freeze              print all repo information
    clone               clone repos
    rename              rename a repo
    flags               git flags configuration
    color               color configuration
    info                information setting
    ll                  display summary of all repos
    context             set context
    ls                  show repo(s) or repo path
    group               group repos
    super               run any git command/alias
    shell               run any shell command
    clear               removes all groups and repositories
    br                  show local branches
    clean               remove all untracked files/folders
    diff                git show differences
    difftool            show differences using a tool
    fetch               fetch remote update
    last                show log information of HEAD
    lo                  show one-line log for the latest 7 commits
    log                 show logs
    merge               merge remote updates
    mergetool           merge updates with a tool
    patch               make a patch
    pull                pull remote updates
    push                push the local updates
    rebase              rebase from master
    reflog              show ref logs
    remote              show remote settings
    reset               reset repo(s)
    show                show detailed commit information
    stash               store uncommited changes
    stat                show edit statistics
    st                  show status
    tag                 show tags

a specific help :
gita st -h :

usage: gita st [-h] [-s SHELL] [{gita,artifactory-cleanup,arch-mu-repo,stackedit-docker,gitlab-branch-source-plugin,analyse_bonnes_pratiques,ul_cnes,open_source,} ...]

show status

positional arguments:
  {gita,artifactory-cleanup,arch-mu-repo,stackedit-docker,gitlab-branch-source-plugin,analyse_bonnes_pratiques,ul_cnes,open_source,[]}
                        show status for all repos or for the chosen repo(s) or group(s)

options:
  -h, --help            show this help message and exit
  -s SHELL, --shell SHELL
                        If set, run in shell mode

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this is great

@Turiok Turiok force-pushed the bugfix/#132_completions_zsh branch from ca7a3fa to 6791680 Compare November 8, 2023 22:42
@nosarthur nosarthur merged commit c0f23d8 into nosarthur:master Nov 9, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants