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

Consider adding subcommand aliases #537

Open
LewisGaul opened this issue Jan 15, 2024 · 1 comment
Open

Consider adding subcommand aliases #537

LewisGaul opened this issue Jan 15, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@LewisGaul
Copy link
Collaborator

When using python-on-whales, there's a slight friction in that certain commands don't map directly to the CLI users of docker/podman are familiar with. The one that caught me out most recently was that client.container.ps() didn't work - it turns out I wanted client.ps() or client.container.list(). Perhaps more confusingly exec is available via a different spelling client.execute() and client.rmi() is not available with any spelling (instead requiring client.image.remove()).

I can see how it's ended up like this, but is it worth considering adding aliases to make things that users are likely to try more likely to "just work"? This isn't something I'd normally suggest, but I think makes sense when trying to mirror a command-line interface.

  • Uncomment DockerClient.rmi() as alias for ImageCLI.remove() for consistency with the CLI (and existence of DockerClient.ps())
  • Add Container.ps() (and Container.ls()?) alias(es) for Container.list() - note that the following are supported on the CLI (alongside docker|podman ps):
    • docker container ls, podman container ls (hidden command)
    • docker container ps (hidden command), podman container ps
    • docker container list (hidden command), podman container list
  • Allow DockerClient.exec() for consistency with the CLI, as an alias for the chosen name DockerClient.execute()?
  • Aliases for similar renaming that has been done, e.g. NetworkCLI.remove() for docker|podman network rm

I'm not suggesting allowing aliases for parameters, however, since that would add significant complexity to method signatures.

@gabrieldemarmiesse
Copy link
Owner

At the time it was made so that the code written with python-on-whales would be more readable than the code written in bash. Looking at it now, I believe that we should allow everything that the CLI allows, not more and not less. The goal of python-on-whales is to have an easy transition from the CLI, let's focus on that. It's up to the users to use what they think is best. Obviously for backward compatibility, we can't remove anything until the 1.0, but I think we can add aliases to mirror exactly what the CLI has.

@gabrieldemarmiesse gabrieldemarmiesse added enhancement New feature or request good first issue Good for newcomers labels Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants