View Issue Details

IDProjectCategoryView StatusLast Update
0013414ScribusUser Interfacepublic2015-11-03 01:08
ReporterjurajF Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformqemuOSLinuxOS VersionDebian 8/Jessie
Product Version1.5.0 
Fixed in Version1.5.1svn 
Summary0013414: [CLI] --lang issues
DescriptionSee Patch 0003-Remove-duplicated-code.patch

--lang option is processed few lines before


See Patch 0004-Wrong-error-when-lang-does-not-have-an-argument.patch

Error message could be more informative.

$ scribus-1.5.1.svn --lang
Invalid argument: --lang
is changed to:
$ scribus-1.5.1.svn --lang
Option --lang require an argument.

Steps To Reproduce$ scribus-1.5.1.svn --lang
Additional InformationCloned from 0013408
TagsNo tags attached.
PatchYes

Relationships

related to 0013413 closedcbradney [CLI] Error-message-wrong-and-too-verbose 
related to 0013415 closedcbradney [CLI] Changing multiple flag rules 
related to 0013408 closedcbradney [CLI] --prefs option without provided file causes crash 
related to 0013452 closedfschmid Can not open ".autosave" file: "is not in an acceptable format" 

Activities

Kunda

2015-10-11 22:57

updater   ~0036635

Coolness. Thanks Juraj. We should get Berteh in to this conversation as well. I'll try to ping him.
0003-Remove-duplicated-code.patch (777 bytes)   
From 767ce2e21c11c8e3a9558f5b468a7ed07a72307b Mon Sep 17 00:00:00 2001
From: Juraj Fedel <wtxnh-scribus@yahoo.com.au>
Date: Sat, 10 Oct 2015 13:22:41 +0200
Subject: [PATCH 3/7] Remove duplicated code

---
 scribus/scribusapp.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index 233eed5..e4e78b1 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -207,9 +207,6 @@ void ScribusQApp::parseCommandLine()
 			header=true;
 			runUpgradeCheck=true;
 		}
-		else if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++argi < argsc)) {
-			continue;
-		} 
 		else if ( arg == ARG_CONSOLE || arg == ARG_CONSOLE_SHORT ) {
 			continue;
 		} else if (arg == ARG_NOSPLASH || arg == ARG_NOSPLASH_SHORT) {
-- 
2.1.4

berteh

2015-10-11 22:57

reporter   ~0036636

Hi Juraj, thanks for the various improvements you brought esp. improving the feedback when arguments are missing a required value (filename in these cases).

just one note regarding your use of "--". I think it's wrong to allow multiple use of it. It usually (as in "in other places where it's used) denotes the end of options and the beginning of positional arguments... and I think it should stay that way.

The reason you mention for needing to enable multiple use was actually not needed, as -pa works just fine if you provide it with just a flag name and then follow with more options (it will detect the starting "-" of the following option and skip looking for its (optional) argument value)... so the only place you needed the "--" is indeed at the very end of options sequence, to make sure the positional arguments (scribus files) are not consumed by -pa.

[it was handled in the line
if (++argi < argsc && !args[argi].startsWith("-")) { // arg value
that you removed in your patch "strange use of delimiter") ]



That being said, I agree with you that forcing -pa to be the last option and consume all that's left of command line (before an optional --) would be less verbose. It's just that othes preferred not having that mechanism, see aoloe at https://github.com/scribusproject/scribus/pull/19#issuecomment-128313027, and cbradney at http://bugs.scribus.net/view.php?id=13311#c36165

... so I guess that part is not an option for the core devs of scribus.

Kunda

2015-10-11 22:57

updater   ~0036637

Last edited: 2015-10-11 23:47

Cloned this issue 0013408 to split up the ticket so we can talk about the different patches in ea. ticket.

Kunda

2015-10-11 22:58

updater  

0004-Wrong-error-when-lang-does-not-have-an-argument.patch (1,197 bytes)   
From ab5220ba68bdf5804c567070d375f6283c10bfe5 Mon Sep 17 00:00:00 2001
From: Juraj Fedel <wtxnh-scribus@yahoo.com.au>
Date: Sat, 10 Oct 2015 13:40:40 +0200
Subject: [PATCH 4/7] Wrong error when --lang does not have an argument

$ scribus-1.5.1.svn  --lang
Invalid argument: --lang

is changed to:

$ scribus-1.5.1.svn  --lang
Option --lang require an argument.
---
 scribus/scribusapp.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index e4e78b1..6543ad2 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -181,8 +181,13 @@ void ScribusQApp::parseCommandLine()
 				pythonScriptArgs.append( QFile::decodeName(args[argi].toLocal8Bit()) );
 			}
 		}
-		else if ((arg == ARG_LANG || arg == ARG_LANG_SHORT) && (++argi < argsc)) {
-			lang = args[argi];
+		else if ((arg == ARG_LANG || arg == ARG_LANG_SHORT)) {
+			if  (++argi < argsc)
+				lang = args[argi];
+			else {
+				std::cout << tr("Option %1 require an argument.").arg(arg).toLocal8Bit().data() << std::endl;
+				std::exit(EXIT_FAILURE);
+			}
 		}
 		else if (arg == ARG_VERSION || arg == ARG_VERSION_SHORT) {
 			header=true;
-- 
2.1.4

Kunda

2015-11-03 01:08

updater   ~0037162

Committed in r20514 by Craig
Patched by Juraj
Thanks

Issue History

Date Modified Username Field Change
2015-10-11 22:57 Kunda New Issue
2015-10-11 22:57 Kunda File Added: 0003-Remove-duplicated-code.patch
2015-10-11 22:57 Kunda Issue generated from: 0013413
2015-10-11 22:57 Kunda Relationship added related to 0013413
2015-10-11 22:58 Kunda File Deleted: 0002-Error-message-wrong-and-too-verbose.patch
2015-10-11 22:58 Kunda File Added: 0004-Wrong-error-when-lang-does-not-have-an-argument.patch
2015-10-11 22:58 Kunda Description Updated
2015-10-11 23:38 Kunda Issue cloned: 0013415
2015-10-11 23:38 Kunda Description Updated
2015-10-11 23:43 Kunda Relationship added related to 0013408
2015-10-11 23:44 Kunda Reporter Kunda => jurajF
2015-10-11 23:45 Kunda Relationship added related to 0013415
2015-10-11 23:47 Kunda Note Edited: 0036637
2015-10-29 04:43 Kunda Relationship added related to 0013452
2015-11-02 10:07 cbradney Status new => resolved
2015-11-02 10:07 cbradney Fixed in Version => 1.5.1svn
2015-11-02 10:07 cbradney Resolution open => fixed
2015-11-02 10:07 cbradney Assigned To => cbradney
2015-11-03 01:08 Kunda Note Added: 0037162
2015-11-03 01:08 Kunda Status resolved => closed