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

poetry zsh completion is missing 'self ...' and some others #360

Open
4 tasks done
alanwilter opened this issue Mar 9, 2023 · 4 comments
Open
4 tasks done

poetry zsh completion is missing 'self ...' and some others #360

alanwilter opened this issue Mar 9, 2023 · 4 comments

Comments

@alanwilter
Copy link

alanwilter commented Mar 9, 2023

  • Poetry version:
    1.4.0
  • Python version:
    3.9.16
  • OS version and name:
    Any OS, tested with mac and linux
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I'm not sure which poetry version lost it (centainly 1.3.2 and 1.4.0 has the issue) but I have an old $ZSH_CUSTOM/plugins/poetry/_poetry where TAB in poetry s..., shows:

search            -- Searches for packages on remote repositories.
self update       -- Updates Poetry to the latest version.
shell             -- Spawns a shell within the virtual environment.
show              -- Shows information about packages.
source add        -- Add source configuration for project.
source remove     -- Remove source configured for the project.
source show       -- Show information about sources configured for the project.

While, the updated one shows:

search               -- Searches for packages on remote repositories.
shell                -- Spawns a shell within the virtual environment.
show                 -- Shows information about packages.

The old _poetry (working autocompletion for self, env, cache ... etc.):

#compdef poetry

_poetry_dbcbaf1a8514368a_complete()
{
    local state com cur

    cur=${words[${#words[@]}]}

    # lookup for command
    for word in ${words[@]:1}; do
        if [[ $word != -* ]]; then
            com=$word
            break
        fi
    done

    if [[ ${cur} == --* ]]; then
        state="option"
        opts=("--ansi:Force ANSI output." "--help:Display help for the given command. When no command is given display help for the list command." "--no-ansi:Disable ANSI output." "--no-interaction:Do not ask any interactive question." "--no-plugins:Disables plugins." "--quiet:Do not output any message." "--verbose:Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug." "--version:Display this application version.")
    elif [[ $cur == $com ]]; then
        state="command"
        coms=("about:Shows information about Poetry." "add:Adds a new dependency to pyproject.toml." "build:Builds a package, as a tarball and a wheel by default." "cache clear:Clears Poetry\'s cache." "cache list:List Poetry\'s caches." "check:Checks the validity of the pyproject.toml file." "config:Manages configuration settings." "debug info:Shows debug information." "debug resolve:Debugs dependency resolution." "env info:Displays information about the current environment." "env list:Lists all virtualenvs associated with the current project." "env remove:Remove virtual environments associated with the project." "env use:Activates or creates a new virtualenv for the current project." "export:Exports the lock file to alternative formats." "help:Displays help for a command." "init:Creates a basic pyproject.toml file in the current directory." "install:Installs the project dependencies." "list:Lists commands." "lock:Locks the project dependencies." "new:Creates a new Python project at <path\>." "plugin add:Adds new plugins." "plugin remove:Removes installed plugins" "plugin show:Shows information about the currently installed plugins." "publish:Publishes a package to a remote repository." "remove:Removes a package from the project dependencies." "run:Runs a command in the appropriate environment." "search:Searches for packages on remote repositories." "self update:Updates Poetry to the latest version." "shell:Spawns a shell within the virtual environment." "show:Shows information about packages." "source add:Add source configuration for project." "source remove:Remove source configured for the project." "source show:Show information about sources configured for the project." "update:Update the dependencies as according to the pyproject.toml file." "version:Shows the version of the project or bumps it when a valid bump rule is provided.")
    fi

    case $state in
        (command)
            _describe 'command' coms
        ;;
        (option)
            case "$com" in

            (about)
            opts+=()
            ;;

            (add)
            opts+=("--allow-prereleases:Accept prereleases." "--dev:Add as a development dependency." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--editable:Add vcs/path dependencies as editable." "--extras:Extras to activate for the dependency." "--group:The group to add the dependency to." "--lock:Do not perform operations \(only update the lockfile\)." "--optional:Add as an optional dependency." "--platform:Platforms for which the dependency must be installed." "--python:Python version for which the dependency must be installed." "--source:Name of the source to use to install the package.")
            ;;

            (build)
            opts+=("--format:Limit the format to either sdist or wheel.")
            ;;

            (cache clear)
            opts+=("--all:Clear all entries in the cache.")
            ;;

            (cache list)
            opts+=()
            ;;

            (check)
            opts+=()
            ;;

            (config)
            opts+=("--list:List configuration settings." "--local:Set/Get from the project\'s local configuration." "--unset:Unset configuration setting.")
            ;;

            (debug info)
            opts+=()
            ;;

            (debug resolve)
            opts+=("--extras:Extras to activate for the dependency." "--install:Show what would be installed for the current system." "--python:Python version\(s\) to use for resolution." "--tree:Display the dependency tree.")
            ;;

            (env info)
            opts+=("--path:Only display the environment\'s path.")
            ;;

            (env list)
            opts+=("--full-path:Output the full paths of the virtualenvs.")
            ;;

            (env remove)
            opts+=("--all:Remove all managed virtual environments associated with the project.")
            ;;

            (env use)
            opts+=()
            ;;

            (export)
            opts+=("--dev:Include development dependencies." "--extras:Extra sets of dependencies to include." "--format:Format to export to. Currently, only requirements.txt is supported." "--output:The name of the output file." "--with-credentials:Include credentials for extra indices." "--without-hashes:Exclude hashes from the exported file." "--without-urls:Exclude source repository urls from the exported file.")
            ;;

            (help)
            opts+=()
            ;;

            (init)
            opts+=("--author:Author name of the package." "--dependency:Package to require, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--description:Description of the package." "--dev-dependency:Package to require for development, with an optional version constraint, e.g. requests:\^2.10.0 or requests=2.11.1." "--license:License of the package." "--name:Name of the package." "--python:Compatible Python versions.")
            ;;

            (install)
            opts+=("--default:Only install the default dependencies." "--dev-only:Only install the development dependencies. \(Deprecated\)" "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--extras:Extra sets of dependencies to install." "--no-dev:Do not install the development dependencies. \(Deprecated\)" "--no-root:Do not install the root package \(the current project\)." "--only:The only dependency groups to install." "--remove-untracked:Removes packages not present in the lock file." "--sync:Synchronize the environment with the locked packages and the specified groups." "--with:The optional dependency groups to include for installation." "--without:The dependency groups to ignore for installation.")
            ;;

            (list)
            opts+=()
            ;;

            (lock)
            opts+=("--check:Check that the poetry.lock file corresponds to the current version of pyproject.toml." "--no-update:Do not update locked versions, only refresh lock file.")
            ;;

            (new)
            opts+=("--name:Set the resulting package name." "--readme:Specify the readme file format. One of md \(default\) or rst" "--src:Use the src layout for the project.")
            ;;

            (plugin add)
            opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\).")
            ;;

            (plugin remove)
            opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\).")
            ;;

            (plugin show)
            opts+=()
            ;;

            (publish)
            opts+=("--build:Build the package before publishing." "--cert:Certificate authority to access the repository." "--client-cert:Client certificate to access the repository." "--dry-run:Perform all actions except upload the package." "--password:The password to access the repository." "--repository:The repository to publish the package to." "--username:The username to access the repository.")
            ;;

            (remove)
            opts+=("--dev:Remove a package from the development dependencies." "--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--group:The group to remove the dependency from.")
            ;;

            (run)
            opts+=()
            ;;

            (search)
            opts+=()
            ;;

            (self update)
            opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--preview:Allow the installation of pre-release versions.")
            ;;

            (shell)
            opts+=()
            ;;

            (show)
            opts+=("--all:Show all packages \(even those not compatible with current system\)." "--default:Only show the information of the default dependencies." "--latest:Show the latest version." "--no-dev:Do not list the development dependencies. \(Deprecated\)" "--only:Only show the information of dependencies belonging to the specified groups." "--outdated:Show the latest version but only for packages that are outdated." "--tree:List the dependencies as a tree." "--with:Show the information of the specified optional groups\' dependencies as well." "--without:Do not show the information of the specified groups\' dependencies.")
            ;;

            (source add)
            opts+=("--default:Set this source as the default \(disable PyPI\). A default source will also be the fallback source if you add other sources." "--secondary:Set this source as secondary.")
            ;;

            (source remove)
            opts+=()
            ;;

            (source show)
            opts+=()
            ;;

            (update)
            opts+=("--dry-run:Output the operations but do not execute anything \(implicitly enables --verbose\)." "--lock:Do not perform operations \(only update the lockfile\)." "--no-dev:Do not update the development dependencies.")
            ;;

            (version)
            opts+=("--short:Output the version number only")
            ;;

            esac

            _describe 'option' opts
        ;;
        *)
            # fallback to file completion
            _arguments '*:file:_files'
    esac
}

_poetry_dbcbaf1a8514368a_complete "$@"
compdef _poetry_dbcbaf1a8514368a_complete /home/awilter/.local/share/pypoetry/venv/bin/poetry
@alanwilter
Copy link
Author

Ok, I think I got it fixed, simply remove the single quotes around e.g. 'self update' in:

coms+=("about:Shows information about Poetry." "add:Adds a new dependency to pyproject.toml." "build:Builds a package, as a tarball and a wheel by default." "cache clear:Clears a Poetry cache by name." "cache list:List Poetry\'s caches." "check:Checks the validity of the pyproject.toml file." "config:Manages configuration settings." "debug info:Shows debug information." "debug resolve:Debugs dependency resolution." "env info:Displays information about the current environment." "env list:Lists all virtualenvs associated with the current project." "env remove:Remove virtual environments associated with the project." "env use:Activates or creates a new virtualenv for the current project." "export:Exports the lock file to alternative formats." "help:Displays help for a command." "init:Creates a basic pyproject.toml file in the current directory." "install:Installs the project dependencies." "list:Lists commands." "lock:Locks the project dependencies." "new:Creates a new Python project at <path\>." "publish:Publishes a package to a remote repository." "remove:Removes a package from the project dependencies." "run:Runs a command in the appropriate environment." "search:Searches for packages on remote repositories." "self add:Add additional packages to Poetry\'s runtime environment." "self install:Install locked packages \(incl. addons\) required by this Poetry installation." "self lock:Lock the Poetry installation\'s system requirements." "self remove:Remove additional packages from Poetry\'s runtime environment." "self show:Show packages from Poetry\'s runtime environment." "self show plugins:Shows information about the currently installed plugins." "self update:Updates Poetry to the latest version." "shell:Spawns a shell within the virtual environment." "show:Shows information about packages." "source add:Add source configuration for project." "source remove:Remove source configured for the project." "source show:Show information about sources configured for the project." "update:Update the dependencies as according to the pyproject.toml file." "version:Shows the version of the project or bumps it when a valid bump rule is provided.")

Shall I do a PR?

@dimbleby
Copy link
Contributor

dimbleby commented Mar 9, 2023

you want to be in the cleo repository, that's what poetry uses for command line matters

#153 (comment) promises a coming refactor, I've no idea whether that's actually happening or not

@branchvincent branchvincent transferred this issue from python-poetry/poetry Aug 21, 2023
@weastur
Copy link

weastur commented Mar 27, 2024

Hi, same problem here

@weastur
Copy link

weastur commented Mar 28, 2024

Anyway, I did a PR for this case.

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 a pull request may close this issue.

3 participants