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

Partial command name matching #262

Open
christian-bromann opened this issue May 22, 2023 · 3 comments
Open

Partial command name matching #262

christian-bromann opened this issue May 22, 2023 · 3 comments

Comments

@christian-bromann
Copy link
Contributor

I've been using npm-run-all where it is possible to say:

npm-run-all foobar:*

which executes all commands prefixed with foobar: starting with the one that is defined first in package.json and ending with the one that is define last. See an example in the current package.json of the WebdriverIO project. Specific to Runme: let's say I have the following markdown files:

fileA.md

```sh { name=task:C }
echo "foo"
```

```sh { name=task:B }
echo "bar"
```

fileB.md

```sh { name=task:A }
echo "loo"
```

Given I run runme --project . run task:* I expect to have the following printed:

foo
bar
loo

so task:C, task:B and task:A. The order is determined by position within a file (first script is executed first) and location of file (alphabetically sorted).

This has been proven for me to be super helpful and a nice mental model to define a stack/pipeline of commands.

It would be nice to eventually see this supported in Runme as well. Wdyat?

@mxsdev
Copy link
Contributor

mxsdev commented May 22, 2023

Would be cool, though there are some ambiguities:

  • How do I determine if the user wants to run a single script vs. many scripts? In other words, when should the user be prompted to select from a list of scripts, and when should they all be ran? One solution here is to use the --all flag.
  • Which query language do we use? Glob and regex don't really suit this purpose. The query language we choose also needs to have decent golang support.

@christian-bromann
Copy link
Contributor Author

  • How do I determine if the user wants to run a single script vs. many scripts? In other words, when should the user be prompted to select from a list of scripts, and when should they all be ran? One solution here is to use the --all flag.

If the user runs runme --project . run task:* they expect all commands to run. I am not sure if there is a usecase where they would expect only the first command to be run.

  • Which query language do we use? Glob and regex don't really suit this purpose. The query language we choose also needs to have decent golang support.

I wonder if it makes sense to come up with a custom query language that fits this particular purpose, e.g.:

  • foobar:* runs foobar:foo or foobar:bar but not foobar:foo:bar
  • foobar:*:* runs foobar:foo:bar but not foobar:foo nor foobar:bar

On the other side, using glob seems to be a viable direction too since it is is so commonly known and well defined.

@mxsdev
Copy link
Contributor

mxsdev commented May 22, 2023

If the user runs runme --project . run task:* they expect all commands to run. I am not sure if there is a usecase where they would expect only the first command to be run.

Currently, if you run runme run (task), it will ask you to select from a list of all matches to "(task)". What do we do when the query task:* matches colliding results across multiple files? If the solution is "run all of them," then this is incompatible with the current implementation.

I wonder if it makes sense to come up with a custom query language that fits this particular purpose, e.g.:

Do you happen to know what happens under the hood for npm-run-all? Perhaps there's a modified version of glob in existence that would be preferable (which would for example match * for multiple results, rather than **)

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

2 participants