3

I am using SailsJS for an application. From front-end i.e. NodeWebkituser will be entering a command which will be sent to server via sockets.

This command is parsed in back-end and a specific service/controller is called.

Socket code is as follows :

socket.on('command', {'command':'user -a -n abhishek -p 123456'})  

I am using JISON for command-line parsing which gets all options in command with their values.

Are there any command parsers better than JISON which I can use here.
Thanks in Advance

1

1 Answer 1

5

You can also use minimist to parse the command.

var cmd = {'command':'user -a -n abhishek -p 123456'}
var argv = require('minimist')(cmd.command.split(' '))
console.dir(argv)

will produce:

{ _: [ 'user' ], a: true, n: 'abhishek', p: 123456 }

then you can:

if (argv['a']) ....
Sign up to request clarification or add additional context in comments.

1 Comment

@Mirosalv If possible could you help me out with this issue in minimist : stackoverflow.com/questions/27021844/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.