Open kran6a opened 3 months ago
I like this idea. Would need to think through when to enter repl mode:
My instinct is yes to 1 and no to all the others, but 4 might be useful too.
Did you have something in mind, how you would want to configure this as a developer, and how you'd want end users to be able to use it?
I would trigger repl mode in two scenarios:
.run
method
import {trpcCli} from 'trpc-cli'
const cli = trpcCli({router: yourRouter})
cli.run({ repl: true //type boolean | string (argument required to trigger the repl mode, bonus points if it is type-checked so that it cannot collide with a router method) })
2. When no command is passed, there is no default command configured and `cli.run()` was NOT called with repl: false (so that you can opt-out of repl in case you are using a cli tool as part of a bash script where entering repl mode would be undesirable).
Add the option to make the CLI app enter a repl loop when executed without arguments (ie:
./cli.ts
). In repl mode you get autocompletion (via the readline autocompletion interface) when typying commands and their arguments.