How are datepickers handled in a CLI environment? Is the most common route to just treat it as a text input with custom validation? Are there custom "controls" that keep formatting and only allow you to edit the digits (think __/__/__
). Would an interactive calendar (possibly rendered using cli-tables and arrow keys
/enter
) be possible/better?
I'm developing a command line app using Node.js and the Vorpal and I would like some sort of datepicker interface.
Other libraries like Inquirer.js provide easy-to-use picklists, checkboxes, and input validation. They act just as they would within a GUI.
The app in question is essentially a task manager app, allowing you to edit tasks to say when you started and stopped. So the dates that are required would refer to ranges (start -> stop) and all relatively recent.
I've never seen a datepicker (GUI) in a CLI app before, but it's totally possible to make it with Vorpal and create a Vorpal extension for it, using these commands.
I've successfully done this type of thing once, in building less
for Vorpal, which does screen redraws based on arrow key movements, etc, which would be a similar endeavor. You can check out the source here for how I do it.
But that's a bit of work.
The other idea (and maybe this can tie into the above) is to simply make a smart-validating date input.
There's a ton of Javascript date libraries like this one that can parse human date strings and standardize them. So you would just do a normal Inquirer
input, and add some validation to it.
Does that help?