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

Don't interpret arguments following long switch (--) as positional #192

Open
WilliamDEdwards opened this issue Jun 25, 2024 · 0 comments
Open

Comments

@WilliamDEdwards
Copy link

WilliamDEdwards commented Jun 25, 2024

For all WP-CLI commands, arguments following a long switch are interpreted as positional without =:

$ wp user list --role admin
Error: Too many positional arguments: admin

$ wp user list --role=admin
+----+------------+--------------+------------+-----------------+-------+
| ID | user_login | display_name | user_email | user_registered | roles |
+----+------------+--------------+------------+-----------------+-------+
+----+------------+--------------+------------+-----------------+-------+

This is unhandy, but acceptable.

However, it becomes a real usablity issue when calling WP-CLI programmatically.

In my case, Python's subprocess.run is used to call WP-CLI (with shell=False for obvious security reasons).

As a result, I have to do this:

command.append(f"--path={self.path}")

... instead of:

command.extend(["--path", self.path])

This way of working delegates string interpolation - and sometimes even quoting - to the caller, which is not developer-friendly (and probably not very POSIX-y).

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

No branches or pull requests

1 participant