Skip to content

Commit

Permalink
introduce a new command line option '--' to the main app
Browse files Browse the repository at this point in the history
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 b4561a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app/main.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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() ) );
Expand Down
11 changes: 11 additions & 0 deletions tests/src/python/test_qgsappstartup.py
Expand Up @@ -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
Expand Down

0 comments on commit b4561a9

Please sign in to comment.