diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-07 10:34:16 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-09-07 10:19:20 +0200 |
commit | 5aec557b414ce7bab24c9aa3e3ea233e1d832c49 (patch) | |
tree | 231783acf3d81db51bab978eddf4484b22a18342 /desktop | |
parent | writerfilter: size() > 0 -> !empty() and other small cleanups (diff) | |
download | core-5aec557b414ce7bab24c9aa3e3ea233e1d832c49.tar.gz core-5aec557b414ce7bab24c9aa3e3ea233e1d832c49.zip |
Improve error messages for not-standalone command line switches
--printer-name and --outdir are only valid command-line parameters
if they directly follow their parent parameters (--print-to-file
and --convert-to). Placing them out-of-order (e.g., using another
parameter between --convert-to and --outdir) results in a generic
message that --outdir is an unknown parameter.
This change makes more useful message for these errors to avoid
user confusion.
Change-Id: I924e8571eec3de9058fe18be3789ccee2bc98c7d
Reviewed-on: https://gerrit.libreoffice.org/42039
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/cmdlineargs.cxx | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index d4bacfb2c33f..d13b5c8b1171 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -563,22 +563,35 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier ) { eCurrentEvent = CommandLineEvent::BatchPrint; } - else if ( eCurrentEvent == CommandLineEvent::BatchPrint && oArg == "printer-name" ) + else if ( oArg == "printer-name" ) { - // first argument is the printer name - if (supplier.next(&aArg)) - m_printername = aArg; + if (eCurrentEvent == CommandLineEvent::BatchPrint) + { + // first argument is the printer name + if (supplier.next(&aArg)) + m_printername = aArg; + else if (m_unknown.isEmpty()) + m_unknown = "--printer-name must be followed by printername"; + } else if (m_unknown.isEmpty()) - m_unknown = "--printer-name must be followed by printername"; + { + m_unknown = "--printer-name must directly follow --print-to-file"; + } } - else if ( (eCurrentEvent == CommandLineEvent::Conversion || - eCurrentEvent == CommandLineEvent::BatchPrint) - && oArg == "outdir" ) + else if ( oArg == "outdir" ) { - if (supplier.next(&aArg)) - m_conversionout = aArg; + if ((eCurrentEvent == CommandLineEvent::Conversion || + eCurrentEvent == CommandLineEvent::BatchPrint)) + { + if (supplier.next(&aArg)) + m_conversionout = aArg; + else if (m_unknown.isEmpty()) + m_unknown = "--outdir must be followed by output directory path"; + } else if (m_unknown.isEmpty()) - m_unknown = "--outdir must be followed by output directory path"; + { + m_unknown = "--outdir must directly follow either output filter specification of --convert-to, or --print-to-file or its printer specification"; + } } else if ( eCurrentEvent == CommandLineEvent::Conversion && oArg == "convert-images-to" ) |