|
@@ -30,6 +30,9 @@ struct options *opts_init(void)
|
|
|
|
|
|
// Initialize
|
|
|
opts->verbose = BOOL_FALSE;
|
|
|
+ opts->stop_on_error = BOOL_FALSE;
|
|
|
+ opts->dry_run = BOOL_FALSE;
|
|
|
+ opts->quiet = BOOL_FALSE;
|
|
|
opts->unix_socket_path = faux_str_dup(KLISH_DEFAULT_UNIX_SOCKET_PATH);
|
|
|
|
|
|
// Don't free command list because elements are the pointers to
|
|
@@ -61,12 +64,15 @@ void opts_free(struct options *opts)
|
|
|
*/
|
|
|
int opts_parse(int argc, char *argv[], struct options *opts)
|
|
|
{
|
|
|
- static const char *shortopts = "hvS:c:";
|
|
|
+ static const char *shortopts = "hvS:c:edq";
|
|
|
static const struct option longopts[] = {
|
|
|
{"socket", 1, NULL, 'S'},
|
|
|
{"help", 0, NULL, 'h'},
|
|
|
{"verbose", 0, NULL, 'v'},
|
|
|
{"command", 1, NULL, 'c'},
|
|
|
+ {"stop-on-error", 0, NULL, 'e'},
|
|
|
+ {"dry-run", 0, NULL, 'd'},
|
|
|
+ {"quiet", 0, NULL, 'q'},
|
|
|
{NULL, 0, NULL, 0}
|
|
|
};
|
|
|
|
|
@@ -85,6 +91,15 @@ int opts_parse(int argc, char *argv[], struct options *opts)
|
|
|
case 'v':
|
|
|
opts->verbose = BOOL_TRUE;
|
|
|
break;
|
|
|
+ case 'e':
|
|
|
+ opts->stop_on_error = BOOL_TRUE;
|
|
|
+ break;
|
|
|
+ case 'd':
|
|
|
+ opts->dry_run = BOOL_TRUE;
|
|
|
+ break;
|
|
|
+ case 'q':
|
|
|
+ opts->quiet = BOOL_TRUE;
|
|
|
+ break;
|
|
|
case 'h':
|
|
|
help(0, argv[0]);
|
|
|
_exit(0);
|
|
@@ -140,12 +155,16 @@ void help(int status, const char *argv0)
|
|
|
name);
|
|
|
} else {
|
|
|
printf("Version : %s\n", VERSION);
|
|
|
- printf("Usage : %s [options]\n", name);
|
|
|
+ printf("Usage : %s [options] [filename] ... [filename]\n", name);
|
|
|
printf("Klish client\n");
|
|
|
printf("Options :\n");
|
|
|
printf("\t-S <path>, --socket=<path> UNIX socket path.\n");
|
|
|
printf("\t-h, --help Print this help.\n");
|
|
|
printf("\t-v, --verbose Be verbose.\n");
|
|
|
- printf("\t-c <line>, --command=<line> Command to execute.\n");
|
|
|
+ printf("\t-c <line>, --command=<line> Command to execute.\n"
|
|
|
+ "\t\tMultiple options are allowed.\n");
|
|
|
+ printf("\t-e, --stop-on-error Stop script execution on error.\n");
|
|
|
+ printf("\t-q, --quiet Disable echo while executing commands\n\t\tfrom the file stream.\n");
|
|
|
+ printf("\t-d, --dry-run Don't actually execute ACTION scripts.\n");
|
|
|
}
|
|
|
}
|