Imagine the git command. It has multiple subcommands, like 'commit' and 'push'.
Now imagine the nodejs REPL mode.
Now combine both and you get something like this:
$> git (drops you into the interactive git command line environment)
git > commit -m"My Message" (run the command and pass all params to this subommand)
The Idea of this whole thing is:
I want to give my cli to inexperienced users, who do rather follow interactive 'instructions on screen' instead of digging through man-pages or cli --help output.
Also, my cli could be stateful in this manner, it could ask you to log in first, save the login token and then put you in some sort of 'Home' menu with mutliple 'commands' which can be executed in the context of this login.
Got it, thanks for the clear explanation!
That's an interesting idea you got.
I'm not quite sure how to build something REPL like (I'll look around for sure!).
But for your use case, I do have an alternative in mind
Because you planned to give your CLI to inexperienced users, what if instead of allowing them to type in the command, you give them a multiple-step prompt just like what I write above with a slightly different approach
Create the CLI as a single type. So it will not have subcommand, simply git (I'll be using git as an example for this)
So when they type:
$ > git
Then they will be presented with the subcommand available (commit, push, etc). Let's say the user chooses commit then the next step you can ask the user to add the message
If they choose push then you can just run the selected action, and not show any next step
Will this be enough for your use case?
I can write a follow-up to this article about the "stateful" CLI, and also publishing the CLI (currently the user needs to have NodeJS installed to get it installed). If you're interested! :)
Cheers,
Chris
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes, thank you for replying!
I mean the following with shell-like Environment:
Imagine the git command. It has multiple subcommands, like 'commit' and 'push'.
Now imagine the nodejs REPL mode.
Now combine both and you get something like this:
$> git (drops you into the interactive git command line environment)
git > commit -m"My Message" (run the command and pass all params to this subommand)
The Idea of this whole thing is:
I want to give my cli to inexperienced users, who do rather follow interactive 'instructions on screen' instead of digging through man-pages or cli --help output.
Also, my cli could be stateful in this manner, it could ask you to log in first, save the login token and then put you in some sort of 'Home' menu with mutliple 'commands' which can be executed in the context of this login.
Have a nice day!
Benjamin
Got it, thanks for the clear explanation!
That's an interesting idea you got.
I'm not quite sure how to build something REPL like (I'll look around for sure!).
But for your use case, I do have an alternative in mind
Because you planned to give your CLI to inexperienced users, what if instead of allowing them to type in the command, you give them a multiple-step prompt just like what I write above with a slightly different approach
Create the CLI as a single type. So it will not have subcommand, simply
git
(I'll be using git as an example for this)So when they type:
$ > git
Then they will be presented with the subcommand available (commit, push, etc). Let's say the user chooses
commit
then the next step you can ask the user to add the messageIf they choose
push
then you can just run the selected action, and not show any next stepWill this be enough for your use case?
I can write a follow-up to this article about the "stateful" CLI, and also publishing the CLI (currently the user needs to have NodeJS installed to get it installed). If you're interested! :)
Cheers,
Chris