Skip to content

Add command-{name|index} and !command-{name|index} condition to --success#318

Merged
gustavohenke merged 7 commits intomasterfrom
success-v2
May 15, 2022
Merged

Add command-{name|index} and !command-{name|index} condition to --success#318
gustavohenke merged 7 commits intomasterfrom
success-v2

Conversation

@gustavohenke
Copy link
Copy Markdown
Member

@gustavohenke gustavohenke commented May 7, 2022

Implements 2 (or 4?) new possible conditions for --success flag:

  • command-{name|index}: command with the specified name or index must exit with 0;
  • !command-{name|index}: all but the command with the specified name or index must exit with 0.

I think that it expanding the use of ! to !first and !last could come next, but for now that's an advanced enough solution!

Closes #280.
Related: #281

@coveralls
Copy link
Copy Markdown

coveralls commented May 9, 2022

Coverage Status

Coverage increased (+0.07%) to 97.879% when pulling 7e0c855 on success-v2 into c5231ea on master.

Copy link
Copy Markdown
Collaborator

@paescuj paescuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gustavohenke, the implementation looks good!

Basically, I like the solution with the command-{name|index} pattern. Just two thoughts from my side:

  • The command name is not unique (while the index is), there can be multiple commands with the same name. It is important to understand that in this case, the command that has finished first (!) will be considered. Should we add a note for this?
  • It can happen that the command with the specified name or index does not exist.
    In the case of !command- concurrently exits with code 0, in the case of command- concurrently exits with code 1. Should we cover this in a test case? Should we also add a note for this?

Comment thread src/completion-listener.ts Outdated
Comment thread src/completion-listener.ts
Comment thread src/completion-listener.ts Outdated
Comment thread src/completion-listener.ts Outdated
@gustavohenke gustavohenke requested a review from paescuj May 13, 2022 11:55
@gustavohenke
Copy link
Copy Markdown
Member Author

there can be multiple commands with the same name

Addressed that. Now all commands with the same name must meet the same condition.
I've also amended --success help to use the plural.

Noteworthy: input handling also accepts a target command name, but it's also only sending it to the first matching command...

It can happen that the command with the specified name or index does not exist.
In the case of !command- concurrently exits with code 0, in the case of command- concurrently exits with code 1.
Should we cover this in a test case? Should we also add a note for this?

Covered it in tests -- might be fine to get away without more docs... I'd love to be able to write more about each flag, but --help already is pretty long 😞

Comment thread src/completion-listener.ts Outdated
Comment on lines +11 to +12
* - `command-{name|index}`: only the command with the specified name or index.
* - `!command-{name|index}`: all commands but the one with the specified name or index.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* - `command-{name|index}`: only the command with the specified name or index.
* - `!command-{name|index}`: all commands but the one with the specified name or index.
* - `command-{name|index}`: only the commands with the specified name or index.
* - `!command-{name|index}`: all commands but the ones with the specified name or index.

@paescuj
Copy link
Copy Markdown
Collaborator

paescuj commented May 13, 2022

Great work, LGTM!

Addressed that. Now all commands with the same name must meet the same condition.
I've also amended --success help to use the plural.

Nice, that makes very much sense 👍

Noteworthy: input handling also accepts a target command name, but it's also only sending it to the first matching command...

Okay, might be something to address in the future...

Covered it in tests -- might be fine to get away without more docs... I'd love to be able to write more about each flag, but --help already is pretty long 😞

Fine for me, I think it's a rare case anyway 👍

Yeah, it would be handy to have a different place to to document such details!

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

Successfully merging this pull request may close these issues.

[Feature Request] Add success condition all but first

3 participants