wp-cli / ideas

💡 Ideas and feature requests are collected here
40 stars 1 forks source link

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

Open WilliamDEdwards opened 5 months ago

WilliamDEdwards commented 5 months ago

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).