parsing - Processing C command line arguments -


how process multiple command line arguments in package manager? giving shot @ writing package manager , right accepting packages install giving me quite headache. example user wants install package x,y , z. right code send 3 different requests function. package names in 1 go. example, user wants install package x,y , z, processed , code send request function stating needs x,y , z , function begin work immediately.

here's current implementation...

case 's':     switch (argv[1][2]) {         case 'u':             id = 1;             alfred("system", "update", "", id);             break;          case 'r':             id = 1;             alfred("system", "reload", "", id);             break;          case 'i':             if (argc - 2 != 0) {                 // loop until packages complete.                 packages = 2; // starting point of packages = argv[2][0]                 srand(time(null)); // seed random number                 id = rand(); // generate random number id                 argc = argc - 2 + 1; // argc minus number of packages , plus 1                 /* inefficent loop! */                 /* must targets , feed alfred */                 while (packages <= argc) {                     alfred("system", "install", &argv[packages][0], id);                     packages++;                 }             } else {                 printf("unrecognized format. execute alfred -h more information.\n");             }             break;          default:             printf("unrecognized format. execute alfred -h more information.\n");             break;     }     break; 

you can try libargtable. used before parse various arguments, it's handy.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -