@@ -103,7 +103,7 @@ from electrum.storage import WalletStorage
103
103
from electrum .util import print_msg , print_stderr , json_encode , json_decode , UserCancelled
104
104
from electrum .util import InvalidPassword
105
105
from electrum .plugin import Plugins
106
- from electrum .commands import get_parser , known_commands , Commands , config_variables
106
+ from electrum .commands import get_parser , get_simple_parser , known_commands , Commands , config_variables
107
107
from electrum import daemon
108
108
from electrum import keystore
109
109
from electrum .util import create_and_start_event_loop , UserFacingException , JsonRPCError
@@ -271,15 +271,21 @@ def sys_exit(i):
271
271
loop_thread .join (timeout = 1 )
272
272
sys .exit (i )
273
273
274
- def parse_command_line () -> Dict :
274
+ def parse_command_line (simple_parser = False ) -> Dict :
275
275
# parse command line from sys.argv
276
- parser = get_parser ()
277
- args = parser .parse_args ()
278
- config_options = args .__dict__
279
- f = lambda key : config_options [key ] is not None and key not in config_variables .get (args .cmd , {}).keys ()
280
- config_options = {key : config_options [key ] for key in filter (f , config_options .keys ())}
281
- if config_options .get (SimpleConfig .NETWORK_SERVER .key ()):
282
- config_options [SimpleConfig .NETWORK_AUTO_CONNECT .key ()] = False
276
+ if simple_parser :
277
+ parser = get_simple_parser ()
278
+ options , args = parser .parse_args ()
279
+ config_options = options .__dict__
280
+ config_options ['cmd' ] = 'gui'
281
+ else :
282
+ parser = get_parser ()
283
+ args = parser .parse_args ()
284
+ config_options = args .__dict__
285
+ f = lambda key : config_options [key ] is not None and key not in config_variables .get (args .cmd , {}).keys ()
286
+ config_options = {key : config_options [key ] for key in filter (f , config_options .keys ())}
287
+ if config_options .get (SimpleConfig .NETWORK_SERVER .key ()):
288
+ config_options [SimpleConfig .NETWORK_AUTO_CONNECT .key ()] = False
283
289
284
290
config_options ['cwd' ] = cwd = os .getcwd ()
285
291
@@ -361,10 +367,11 @@ def main():
361
367
# save sys args for next parser
362
368
saved_sys_argv = sys .argv [:]
363
369
# disable help, the next parser will display it
364
- if '-h' in sys .argv :
365
- sys .argv .remove ('-h' )
370
+ for x in sys .argv :
371
+ if x in ['-h' , '--help' ]:
372
+ sys .argv .remove (x )
366
373
# parse first without plugins
367
- config_options = parse_command_line ()
374
+ config_options = parse_command_line (simple_parser = True )
368
375
tmp_config = SimpleConfig (config_options )
369
376
# load (only) the commands modules of plugins so their commands are registered
370
377
plugin_commands = Plugins (tmp_config , cmd_only = True )
0 commit comments