reset password
Author Message
jpascua
Posts: 197
Posted 17:17 Oct 17, 2015 |

I've been trying to figure out how to read in two flags and perform the following actions for a while now with no avail.

Does anyone have a hint?

Thanks in advance.

 

giraid
Posts: 39
Posted 17:24 Oct 17, 2015 |

like --math 13 --fact 26?

if so, you dont read in two flags, you read in a collective flags. flags.math will contain 13 and flags.fact will contain 26. hope this helps.

jpascua
Posts: 197
Posted 17:35 Oct 17, 2015 |
giraid wrote:

like --math 13 --fact 26?

if so, you dont read in two flags, you read in a collective flags. flags.math will contain 13 and flags.fact will contain 26. hope this helps.

I meant the --math 13 --save part of the assignment. When I try running this on my cli, only the math flag gets called but not save.

giraid
Posts: 39
Posted 17:42 Oct 17, 2015 |

you could test whether save is present with if (flags.save)

jpascua
Posts: 197
Posted 17:45 Oct 17, 2015 |

Gotcha!

pchavda
Posts: 12
Posted 18:32 Oct 17, 2015 |

if you want to retrive save flag from --math 13 --save you can use following code. works with yargs library.

just define 

var argv = require('yargs').argv;

and check following condition:

if(argv.save){

}

Last edited by pchavda at 18:34 Oct 17, 2015.