chiark / gitweb /
no dupe warning on cancel
[hippotat.git] / hippotat / __init__.py
index 0b059e59e2384d0b20cf388ec17887198e66c8ae..d8b119a2b5c70d345605231dc6e2e2920dbfba8d 100644 (file)
@@ -413,28 +413,33 @@ def common_startup():
     debug_set = set(dfs_less_detailed(debug_def_detail))
 
   def ds_select(od,os, spec, op):
-    last_df = next(DBG.iterconstants())
-    mutator = debug_set.add
-
     for it in spec.split(','):
 
-      if not len(it):
-        for df in dfs_less_detailed(last_df):
-          mutator(df)
-        continue
-
       if it.startswith('-'):
         mutator = debug_set.discard
         it = it[1:]
       else:
         mutator = debug_set.add
-        
-      try:
-        df = DBG.lookupByName(it)
-      except ValueError:
-        optparser.error('unknown debug flag %s in --debug-select' % it)
-      mutator(df)
-      last_df = df
+
+      if it == '+':
+        dfs = DBG.iterconstants()
+
+      else:
+        if it.endswith('+'):
+          mapper = dfs_less_detailed
+          it = it[0:len(it)-1]
+        else:
+          mapper = lambda x: [x]
+
+          try:
+            dfspec = DBG.lookupByName(it)
+          except ValueError:
+            optparser.error('unknown debug flag %s in --debug-select' % it)
+
+        dfs = mapper(dfspec)
+
+      for df in dfs:
+        mutator(df)
 
   optparser.add_option('-D', '--debug',
                        nargs=0,
@@ -445,18 +450,19 @@ def common_startup():
   optparser.add_option('--debug-select',
                        nargs=1,
                        type='string',
-                       metavar='[-]DFLAG[,],...',
+                       metavar='[-]DFLAG[+]|[-]+,...',
                        help=
-'''enable (or with -, disable) each specified DFLAG;
-empty entry means do the same for all DFLAGS "more interesting"
-than the last (or, all DFLAGs)''',
+'''enable (`-': disable) each specified DFLAG;
+`+': do same for all "more interesting" DFLAGSs;
+just `+': all DFLAGs.
+  DFLAGS: ''' + ' '.join([df.name for df in DBG.iterconstants()]),
                        action='callback',
                        callback= ds_select)
 
   (opts, args) = optparser.parse_args()
   if len(args): optparser.error('no non-option arguments please')
 
-  print(repr(debug_set), file=sys.stderr)
+  #print(repr(debug_set), file=sys.stderr)
 
   re = regexp.compile('#.*')
   cfg.read_string(re.sub('', defcfg))