Sunday 23 July 2017

Is there a module for splitting arbitrary command line commands into arrays?

Let's say I have the following command stored as a string:cp My\ Pictures/cute\ kitty.jpg "/mnt/USB/my secret stash/" I want it parsed as an array:['cp', 'My Pictures/cute kitty.jpg', '/mnt/USB/my secret stash/'] Is there an existing module that can do this?Note that I'm not looking for things like minimist or yargs. These parsers operate on process.argv, which is already an array.For now I've cobbled something together using string-tokenizer, but it doesn't handle the edge cases above.

Submitted July 23, 2017 at 07:08PM by JoeyMallone

No comments:

Post a Comment