- updated the new Tcl command: now it has an argument -keep_scripts that when True, will keep the loaded scripts in the new project
This commit is contained in:
@@ -19,6 +19,7 @@ class TclCommandNew(TclCommand):
|
||||
# dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
|
||||
option_types = collections.OrderedDict([
|
||||
('reset', str),
|
||||
('keep_scripts', str)
|
||||
])
|
||||
|
||||
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
||||
@@ -26,12 +27,14 @@ class TclCommandNew(TclCommand):
|
||||
|
||||
# structured help for current command, args needs to be ordered
|
||||
help = {
|
||||
'main': "Starts a new project. Clears objects from memory.",
|
||||
'main': "Starts a new project. Clears objects from memory. Default action: reset the Tcl environment.",
|
||||
'args': collections.OrderedDict([
|
||||
('reset', 'If True/0 or missing (default value) or no value provided then the Tcl is re-instantiated '
|
||||
('reset', 'If True/1 or missing (default value) or no value provided then the Tcl is re-instantiated '
|
||||
'thus resetting all its variables.'),
|
||||
('keep_scripts', 'If True/1, all script objects are kept in the new project. '
|
||||
'Default: scripts are not kept.')
|
||||
]),
|
||||
'examples': ['new', 'new -reset False']
|
||||
'examples': ['new', 'new -reset False', 'new -keep_scripts False']
|
||||
}
|
||||
|
||||
def execute(self, args, unnamed_args):
|
||||
@@ -46,7 +49,20 @@ class TclCommandNew(TclCommand):
|
||||
|
||||
reset_tcl = True
|
||||
if 'reset' in args:
|
||||
if args['reset'] and (args['reset'] == 0 or args['reset'].lower() == 'false'):
|
||||
reset_tcl = False
|
||||
if args['reset']:
|
||||
try:
|
||||
reset_tcl = bool(eval(str(args['reset'])))
|
||||
except NameError:
|
||||
if args['reset'].lower() == 'false':
|
||||
reset_tcl = False
|
||||
|
||||
self.app.f_handlers.on_file_new_project(cli=True, reset_tcl=reset_tcl, silenced=True)
|
||||
keep_scripts = False
|
||||
if 'keep_scripts' in args:
|
||||
if args['keep_scripts']:
|
||||
try:
|
||||
keep_scripts = bool(eval(str(args['keep_scripts'])))
|
||||
except NameError:
|
||||
if args['keep_scripts'].lower() == 'true':
|
||||
keep_scripts = True
|
||||
|
||||
self.app.f_handlers.on_file_new_project(cli=True, reset_tcl=reset_tcl, silenced=True, keep_scripts=keep_scripts)
|
||||
|
||||
Reference in New Issue
Block a user