gabrieldemarmiesse / python-on-whales

An awesome Python wrapper for an awesome Docker CLI!
MIT License
541 stars 101 forks source link

Consider adding subcommand aliases #537

Open LewisGaul opened 8 months ago

LewisGaul commented 8 months ago

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.

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

gabrieldemarmiesse commented 8 months ago

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.