[Libreoffice-commits] core.git: desktop/source

Mike Kaganski mike.kaganski at collabora.com
Thu Sep 7 08:19:43 UTC 2017


 desktop/source/app/cmdlineargs.cxx |   35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

New commits:
commit 5aec557b414ce7bab24c9aa3e3ea233e1d832c49
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Sep 7 10:34:16 2017 +0300

    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 at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>

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" )


More information about the Libreoffice-commits mailing list