Non ambigous Argmuent and Flag position #581

Open
opened 2024-03-07 17:37:42 +00:00 by p4u1 · 8 comments
Member

Let's take abra app cmd as an example, since we also have a real problem here

Currently the command usage is advertised the following:

USAGE:
   abra app command [command options] <domain> [<service>] <command> [-- <args>]

So I can run the following:

abra app cmd --local abra-test-recipe.local test_cmd_arg

But it is also possible to set [command options] after the like this:

abra app cmd abra-test-recipe.local test_cmd_arg --local 

This behaviour was explicitly restored in this commit 0e688f1407 by downgrading our cli library urfave/cli from v2 to v1.

This had the consequence, that the following does not work anymore:

abra app cmd --local abra-test-recipe.local test_cmd_arg -- bing

I prose to upgrade urfave/cli back to v2 and there only allow command options directly after the command as it is also currently advertised.

In coop-cloud/abra#404 i implemented the upgrade, whats left is fixing all option usages in the integration tests. If accepted I am willing to do the rest of the work.

Let's take `abra app cmd` as an example, since we also have a real problem here Currently the command usage is advertised the following: ``` USAGE: abra app command [command options] <domain> [<service>] <command> [-- <args>] ``` So I can run the following: ``` abra app cmd --local abra-test-recipe.local test_cmd_arg ``` But it is also possible to set [command options] after the <command> like this: ``` abra app cmd abra-test-recipe.local test_cmd_arg --local ``` This behaviour was explicitly restored in this commit https://git.coopcloud.tech/coop-cloud/abra/commit/0e688f1407a1f17333ea6cf4c4f64ba9b9d800fa by downgrading our cli library `urfave/cli` from v2 to v1. This had the consequence, that the following does not work anymore: ``` abra app cmd --local abra-test-recipe.local test_cmd_arg -- bing ``` I prose to upgrade `urfave/cli` back to v2 and there only allow command options directly after the command as it is also currently advertised. In https://git.coopcloud.tech/coop-cloud/abra/pulls/404 i implemented the upgrade, whats left is fixing all option usages in the integration tests. If accepted I am willing to do the rest of the work.
p4u1 added the
abra
label 2024-03-07 17:37:42 +00:00
Owner

@p4u1 thanks for raising.

@3wordchant any thoughts?

@p4u1 thanks for raising. @3wordchant any thoughts?
Member

My vote does not matter much (given I have zero deployments atm), but in terms of general codebase health- I thinking upgrading to urfave/cli#v2 is best. Release of v2.27.1 was in Dec, 2023 containing over 5 years and 100 smaller releases with what looks like many fixes and small improvements. They're already working on a v3. releases of cli 🤯

I have no idea how much this will screw up people's deployments and flows. Objectively speaking, I think this makes a truckload 🚚 🧠 more sense for the a longer term health of abra and Co-op Cloud to upgrade.

My vote does not matter much (given I have zero deployments atm), but in terms of general codebase health- I thinking upgrading to `urfave/cli#v2` is best. Release of `v2.27.1` was in Dec, 2023 containing over 5 years and 100 smaller releases with what looks like many fixes and small improvements. They're already working on a `v3.` releases of `cli` 🤯 I have no idea how much this will screw up people's deployments and flows. Objectively speaking, I think this makes a truckload 🚚 🧠 more sense for the a longer term health of `abra` and Co-op Cloud to upgrade.
Owner

Additional data points:

From what I can remember in #284, we were forced in v2 to put [command options] only before the <command> and this was causing people issues. This is not "only allow command options directly after the command" @p4u1?

I've just built a local copy of coop-cloud/abra#404 and this is still the case:

🌻 ./abra app cmd --local abra-test-recipe.foo.org test_cmd_arg -- foo
foo
🌻 ./abra app cmd abra-test-recipe.foo.org test_cmd_arg --local -- foo
FATA[0000] abra-test-recipe doesn't have a --local function

I'm very confused again.

Additional data points: * https://git.coopcloud.tech/coop-cloud/organising/issues/284 * https://git.coopcloud.tech/coop-cloud/organising/issues/352 From what I can remember in #284, we were forced in v2 to put `[command options]` *only* before the `<command>` and this was causing people issues. This is not "only allow command options directly after the command" @p4u1? I've just built a local copy of https://git.coopcloud.tech/coop-cloud/abra/pulls/404 and this is still the case: > 🌻 ./abra app cmd --local abra-test-recipe.foo.org test_cmd_arg -- foo > foo > 🌻 ./abra app cmd abra-test-recipe.foo.org test_cmd_arg --local -- foo > FATA[0000] abra-test-recipe doesn't have a --local function I'm very confused again.
Owner

Annnnd this: #361

@p4u1 v3 upgrade spike? 😱

Annnnd this: https://git.coopcloud.tech/coop-cloud/organising/issues/361 @p4u1 v3 upgrade spike? 😱
Owner

Update: we're leaving this in the new release as it's not a new regression and the fix for it needs some serious work. It's a rather minor bug which at least @moritz was able to figure out how to make work... very not ideal but we're so far behind on this release work, it seems like the best way forward now.

Update: we're leaving this in the new release as it's not a new regression and the fix for it needs some serious work. It's a rather minor bug which at least @moritz was able to figure out how to make work... very not ideal but we're so far behind on this release work, it seems like the best way forward now.
p4u1 referenced this issue from a commit 2024-03-11 13:27:21 +00:00
p4u1 referenced this issue from a commit 2024-03-11 13:29:01 +00:00
Owner

Maybe a survey of other CLI tools which support multiple word commands, to see which of them have restrictions on option placement, could be useful? And/or some UX testing on this?

In the mean-time, @p4u1, could you clarify what's not working in abra app cmd --local abra-test-recipe.local test_cmd_arg -- bing?

It seems like bing is meant to be passed to test_cmd_arg, and --local is meant to be handled by abra, correct? What is happening instead?

Maybe a survey of other CLI tools which support multiple word commands, to see which of them have restrictions on option placement, could be useful? And/or some UX testing on this? In the mean-time, @p4u1, could you clarify what's not working in `abra app cmd --local abra-test-recipe.local test_cmd_arg -- bing`? It seems like `bing` is meant to be passed to `test_cmd_arg`, and `--local` is meant to be handled by `abra`, correct? What is happening instead?
decentral1se added the
bug
label 2024-03-27 06:15:52 +00:00
Owner

@p4u1 and myself re-attempted to explain this to ourselves today... brain melter!

  • passing -- on the end as [-- ARGS] is broken, (-- gets parsed as an argument)
  • --local on the end, doesn't actually work:
    • the library parser doesn't include --local in the c.Args() if you pass it in the abra app cmd --local <domain> position (works!) but it is included if you pass it in the abra app cmd <domain> --local and this breaks code in abra that checks position of c.Args() for arguments. Since urfave/cli is generating abra app command command [command options] <domain> [<service>] <command> [-- <args>] as the help, it means we're actually somehow abusing the fact that options can be passed after commands? We believe this is why they released the "breaking change" in v2, which was just fixing this bug. Hence, forcing people to adhere to advertised usage?
  • seems to only (?) affects mostly abra app cmd because the interface is quite weird
@p4u1 and myself re-attempted to explain this to ourselves today... brain melter! * passing `--` on the end as `[-- ARGS]` is broken, (`--` gets parsed as an argument) * `--local` on the end, doesn't actually work: * the library parser doesn't include `--local` in the `c.Args()` if you pass it in the `abra app cmd --local <domain>` position (works!) but it *is* included if you pass it in the `abra app cmd <domain> --local` and this breaks code in `abra` that checks position of `c.Args()` for arguments. Since `urfave/cli` is generating `abra app command command [command options] <domain> [<service>] <command> [-- <args>]` as the help, it means we're actually somehow abusing the fact that options can be passed after commands? We believe this is why they released the "breaking change" in v2, which was just fixing this bug. Hence, forcing people to adhere to advertised usage? * seems to only (?) affects mostly `abra app cmd` because the interface is quite weird
Owner
https://docs.coopcloud.tech/abra/trouble/#command-line-flag-handling-is-weird https://git.coopcloud.tech/coop-cloud/docs.coopcloud.tech/pulls/256/files#diff-cc94fdc55a0f6e6e79d71b15081836752766bb20 😱
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coop-cloud/organising#581
No description provided.