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

completion option for zsh #64

Open
brucechou1983 opened this issue Apr 14, 2017 · 9 comments
Open

completion option for zsh #64

brucechou1983 opened this issue Apr 14, 2017 · 9 comments

Comments

@brucechou1983
Copy link

I'm using zsh 5.0.8 on OSX 10.11.6.

When I tried to run the generated completion bash for the basic example in README, I got the following error.

_complete-calculatorpy:4: unrecognized modifier C'`

I finally resolved this issue by replacing the : in the bash script with : .

An extra option for completion command will be helpful for zsh user.

@dbieber
Copy link
Member

dbieber commented May 23, 2017

I finally resolved this issue by replacing the : in the bash script with :.

I don't follow -- you replaced a colon with a different colon?
It would be great to have zsh support, but I haven't looked into supporting it yet.
(I would also like a single completion script to work for all Fire CLIs, instead of having to generate one per CLI, but that's a bigger task than adding zsh support.)

@pierrejeambrun
Copy link

pierrejeambrun commented Oct 28, 2019

He changed the semi column with a semi column followed by a space. It seems to work but I have some weird autocompletion problem after the first argument, I don't know if this is the normal behavior though. (I cannot autocomplete other arguments or path after the first argument is selected)

@llabusch93
Copy link

Hey guys,

is ZSH auto completion support planned?

Thanks for a followup.

@loynoir
Copy link

loynoir commented May 5, 2021

Ran into same issue.

unrecognized modifier `C'

Solved

@SedMek
Copy link

SedMek commented Oct 12, 2022

Thank you @loynoir for attempting to fix the issue, but it seems to me that your PR was closed, thus the problem of completion remains the same.

@loynoir
Copy link

loynoir commented Oct 12, 2022

@SedMek

  • Ah, I signed CLA, but later merged iln-sk changes for some extra types, who seems not signed CLA, and PR got blocked by CLA bot.
  • Plus I not using fire now, so I closed that blocked PR.

2faa993

@bukowa
Copy link

bukowa commented Feb 13, 2023

@SedMek

  • Ah, I signed CLA, but later merged iln-sk changes for some extra types, who seems not signed CLA, and PR got blocked by CLA bot.
  • Plus I not using fire now, so I closed that blocked PR.

2faa993

Does not work for me :(

maximehk pushed a commit to maximehk/python-fire that referenced this issue Nov 13, 2023
dbieber pushed a commit that referenced this issue Nov 13, 2023
Related issue  #64

Co-authored-by: Max Hacker <[email protected]>
@maximehk
Copy link
Contributor

The issue that triggered the unrecognized modifier error in ZSH should be fixed at head now. You can try and force re-installing the python-fire package.

pip install --upgrade --force-reinstall python-fire

@GabLeRoux
Copy link

GabLeRoux commented Dec 12, 2023

I confirm the zsh completion works with zsh on latest commit d44d33d . To test it, this is what I did:

git clone [email protected]:google/python-fire.git
cd python-fire
python setup.py install

Here's a simple example

#!/usr/bin/env python

import fire

class Calculator:

    def add(self, a, b):
        return a + b

    def subtract(self, a, b):
        return a - b

    def multiply(self, a, b):
        return a * b

    def divide(self, a, b):
        return a / b

if __name__ == '__main__':
    fire.Fire(Calculator)

Named it calculator and added it to a folder which is in my PATH, then generated completions like this:

calculator -- --completion > calculator-completion
source calculator-completion

I confirm completions work fine:

CleanShot 2023-12-11 at 22 01 17@2x

CleanShot 2023-12-11 at 22 01 28@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants