Skip to content
Permalink
Browse files

introduce a new command line option '--' to the main app

all arguments after this option are treated as files, not options
includes a test
  • Loading branch information
SebDieBln committed Nov 22, 2015
1 parent 91ad208 commit b4561a92836d496b455c2654ccac05b55e8c8d7a
Showing with 18 additions and 1 deletion.
  1. +7 −1 src/app/main.cpp
  2. +11 −0 tests/src/python/test_qgsappstartup.py
@@ -133,7 +133,8 @@ void usage( std::string const & appName )
<< "\t[--dxf-scale-denom scale]\tscale for dxf output\n"
<< "\t[--dxf-encoding encoding]\tencoding to use for dxf output\n"
<< "\t[--dxf-preset visiblity-preset]\tlayer visibility preset to use for dxf output\n"
<< "\t[--help]\t\tthis text\n\n"
<< "\t[--help]\t\tthis text\n"
<< "\t[--]\t\ttreat all following arguments as FILEs\n\n"
<< " FILE:\n"
<< " Files specified on the command line can include rasters,\n"
<< " vectors, and QGIS project files (.qgs): \n"
@@ -683,6 +684,11 @@ int main( int argc, char *argv[] )
{
dxfPreset = args[++i];
}
else if ( arg == "--" )
{
for ( i++; i < args.size(); ++i )
myFileList.append( QDir::toNativeSeparators( QFileInfo( args[i] ).absoluteFilePath() ) );
}
else
{
myFileList.append( QDir::toNativeSeparators( QFileInfo( args[i] ).absoluteFilePath() ) );
@@ -165,6 +165,17 @@ def testPyQgisStartupEnvVar(self):
timeOut=15,
env={'PYQGIS_STARTUP': testmod}), msg

def testOptionsAsFiles(self):
# verify QGIS accepts filenames that match options after the special option '--'
# '--help' should return immediatly (after displaying the usage hints)
# '-- --help' should not exit but try (and probably fail) to load a layer called '--help'
for t in [(False, ['--help']), (True, ['--', '--help'])]:
assert t[0] == self.doTestStartup(option="--configpath",
testDir=os.path.join(self.TMP_DIR, 'test_optionsAsFiles'),
testFile="qgis.db",
timeOut=15,
additionalArguments = t[1]), "additional arguments: %s" % ' '.join(t[1])


if __name__ == '__main__':
# look for qgis bin path

0 comments on commit b4561a9

Please sign in to comment.
You can’t perform that action at this time.