@@ -106,7 +106,7 @@ void printHelp(Printer& log, const string& mode, bool showHeader)
106106
107107 if (mode != " y" ) {
108108 log.println (" -o, --output=<outputName>" , true );
109-
109+
110110 if (mode == " c" ) {
111111 log.println (" Optional name of the output file or directory (defaults to" , true );
112112 log.println (" <inputName.knz> if input is <inputName> or 'stdout' if input is 'stdin')." , true );
@@ -343,6 +343,11 @@ void printHeader(Printer& log, int verbose, bool& showHeader)
343343 ss << " Warning: ignoring option [" << opt << " ]. Only applicable in decompression mode." ; \
344344 log.println(ss.str(), verbose > 0 )
345345
346+ #define WARNING_OPT_INVALID (opt ) \
347+ stringstream ss; \
348+ ss << " Warning: ignoring option [" << opt << " ]. Not applicable in this mode." ; \
349+ log.println(ss.str(), verbose > 0 )
350+
346351#define WARNING_OPT_DUPLICATE (opt, val ) \
347352 stringstream ss; \
348353 ss << " Warning: ignoring duplicate option [" << opt << " ]: " << val;\
@@ -488,7 +493,7 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
488493 }
489494 else {
490495 if (mode == " y" ) {
491- log. println ( " Warning: ignoring option [ " + outputName + " ]. Only applicable in compression or decompression mode. " , verbose > 0 );
496+ WARNING_OPT_INVALID ( outputName);
492497 }
493498 else {
494499 string str = outputName;
@@ -538,7 +543,8 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
538543 }
539544
540545 if (mode == " y" ) {
541- WARNING_OPT_COMP_ONLY (arg);
546+ WARNING_OPT_INVALID (arg);
547+ ctx = - 1 ;
542548 continue ;
543549 }
544550
@@ -590,12 +596,14 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
590596 WARNING_OPT_DUPLICATE (arg, " true" );
591597 }
592598
599+ ctx = -1 ;
600+
593601 if (mode == " y" ) {
594- WARNING_OPT_COMP_ONLY (arg);
602+ WARNING_OPT_INVALID (arg);
595603 continue ;
596604 }
605+
597606 remove = 1 ;
598- ctx = -1 ;
599607 continue ;
600608 }
601609
@@ -662,11 +670,20 @@ int processCommandLine(int argc, const char* argv[], Context& map, Printer& log)
662670
663671 if (outputName != " " ) {
664672 string msg = (ctx == ARG_IDX_OUTPUT) ? CMD_LINE_ARGS[ctx] : arg;
673+
674+ if (mode == " y" ) {
675+ WARNING_OPT_INVALID (msg);
676+ ctx = -1 ;
677+ continue ;
678+ }
679+
665680 WARNING_OPT_DUPLICATE (msg, arg);
666681 }
667682 else {
668683 if (mode == " y" ) {
669- WARNING_OPT_COMP_ONLY (arg);
684+ string msg = (ctx == ARG_IDX_OUTPUT) ? CMD_LINE_ARGS[ctx] : arg;
685+ WARNING_OPT_INVALID (msg);
686+ ctx = -1 ;
670687 continue ;
671688 }
672689
0 commit comments