Skip to content

Allow plugin arguments to be passed always #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions qt_gui/src/qt_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ def add_arguments(self, parser, standalone=False, plugin_argument_provider=None)
'-v', '--verbose', dest='verbose', default=False, action='store_true',
help='output qDebug messages')

if not standalone:
common_group.add_argument(
'--args', dest='plugin_args', nargs='*', type=str,
help='arbitrary arguments which are passes to the plugin '
'(only with -s, --command-start-plugin or --embed-plugin). '
'It must be the last option since it collects all following options.')
common_group.add_argument(
'--args', dest='plugin_args', nargs='*', type=str,
help='arbitrary arguments which are passes to the plugin '
'(only with -s, --command-start-plugin or --embed-plugin). '
'It must be the last option since it collects all following options.')

if not standalone:
group = parser.add_argument_group(
'Options to query information without starting a GUI instance',
'These options can be used to query information about valid arguments for various '
Expand Down Expand Up @@ -232,12 +232,11 @@ def main(self, argv=None, standalone=None, plugin_argument_provider=None,
arguments = argv[1:]

# extract plugin specific args when not being invoked in standalone mode programmatically
if not standalone:
plugin_args = []
if '--args' in arguments:
index = arguments.index('--args')
plugin_args = arguments[index + 1:]
arguments = arguments[0:index + 1]
plugin_args = []
if '--args' in arguments:
index = arguments.index('--args')
plugin_args = arguments[index + 1:]
arguments = arguments[0:index + 1]

parser = ArgumentParser(os.path.basename(Main.main_filename), add_help=False)
self.add_arguments(parser, standalone=bool(standalone),
Expand Down Expand Up @@ -270,14 +269,6 @@ def main(self, argv=None, standalone=None, plugin_argument_provider=None,

# check option dependencies
try:
if self._options.plugin_args and \
not self._options.standalone_plugin and \
not self._options.command_start_plugin and \
not self._options.embed_plugin:
raise RuntimeError(
'Option --args can only be used together with either --standalone, '
'--command-start-plugin or --embed-plugin option')

if self._options.freeze_layout and not self._options.lock_perspective:
raise RuntimeError(
'Option --freeze_layout can only be used together with the '
Expand Down