Whiteknight / StoneFruit

Cli commandlet host and execution environment
https://whiteknight.github.io/StoneFruit/
Apache License 2.0
0 stars 0 forks source link

Verbs to invoke external applications #7

Open Whiteknight opened 4 years ago

Whiteknight commented 4 years ago

For example, git mycommand will search $PATH to find git-mycommand and invoke it with the remainder of the commandline filled in (and maybe a few other bits of context as well)

Whiteknight commented 3 years ago

Need to think about the syntax here, because we're going to need to format StoneFruit-style args into shell-style args, and we don't know which shell the user is running. If we want to use a format string similarly to Scripts, we'll need syntax to cover a lot of cases (output literal values in response to the presence or absence of a flag, output named values in a way that doesn't require us to make any assumptions about what the named output format should be, etc)

Or instead of a script we could let code handle it. In which case we probably want to just provide an external app invoker, and let a custom Handler type assemble the commandline.

Whiteknight commented 2 years ago

There are two different concepts that would need to be implemented.

First, when we type in "myapp foo" we want it to redirect to something like "myapp-foo.exe" or whatever. We need to specify a format string of things to search for, and then look in the local folder and PATH to see if anything matches. Then, we need to find a way to format the arguments from the stonefruit syntax to the args format of the application. This is a HandlerSource that will look in PATH for a matching argument and try to invoke it. We might want to declare that apps invoked in this way must just have the same arguments format as StoneFruit uses.

Second, we want to setup something like a Script, where we translate a single stonefruit command into a single app/args instruction. In this case we don't necessarily need to use the same arguments syntax, we can translate.