Lichen

Changeset

612:97ec110d65cf
2017-02-23 Paul Boddie raw files shortlog changelog graph Added a "reset all" option removing the data directory. Added option synonyms. method-wrapper-for-context
docs/lplc.1 (file) lplc (file)
     1.1 --- a/docs/lplc.1	Thu Feb 23 16:37:43 2017 +0100
     1.2 +++ b/docs/lplc.1	Thu Feb 23 16:39:02 2017 +0100
     1.3 @@ -24,31 +24,34 @@
     1.4  The following options may be specified:
     1.5  .PP
     1.6  .TP
     1.7 -.B \-c
     1.8 -Only partially compile the program; do not attempt to build or link it
     1.9 +.BR \-c ", " \-\-compile
    1.10 +Only partially compile the program; do not build or link it
    1.11  .TP
    1.12 -.B \-E
    1.13 +.BR \-E ", " \-\-no\-env
    1.14  Ignore environment variables affecting the module search path
    1.15  .TP
    1.16 -.B \-g
    1.17 +.BR \-g ", " \-\-debug
    1.18  Generate debugging information for the built executable
    1.19  .TP
    1.20 -.B \-P
    1.21 +.BR \-P ", " \-\-show\-path
    1.22  Show the module search path
    1.23  .TP
    1.24 -.B \-q
    1.25 +.BR \-q ", " \-\-quiet
    1.26  Silence messages produced when building an executable
    1.27  .TP
    1.28 -.B \-r
    1.29 -Reset (discard) cached program information; inspect the whole program again
    1.30 +.BR \-r ", " \-\-reset
    1.31 +Reset (discard) cached information; inspect the whole program again
    1.32  .TP
    1.33 -.B \-t
    1.34 +.BR \-R ", " \-\-reset\-all
    1.35 +Reset (discard) all program details including translated code
    1.36 +.TP
    1.37 +.BR \-t ", " \-\-no\-timing
    1.38  Silence timing messages
    1.39  .TP
    1.40 -.B \-tb
    1.41 +.BR \-tb ", " \-\-traceback
    1.42  Provide a traceback for any internal errors (development only)
    1.43  .TP
    1.44 -.B \-v
    1.45 +.BR \-v ", " \-\-verbose
    1.46  Report compiler activities in a verbose fashion (development only)
    1.47  .PP
    1.48  Some options may be followed by values, either immediately after the option
    1.49 @@ -93,7 +96,7 @@
    1.50  A collection of directories that are searched before those in the collection
    1.51  comprising the default "module search path". This collection, if already defined
    1.52  in the environment, may be excluded by specifying the
    1.53 -.B \-E
    1.54 +.BR \-E " (or " \-\-no\-env )
    1.55  option.
    1.56  .SH AUTHOR
    1.57  Paul Boddie <paul@boddie.org.uk>
     2.1 --- a/lplc	Thu Feb 23 16:37:43 2017 +0100
     2.2 +++ b/lplc	Thu Feb 23 16:39:02 2017 +0100
     2.3 @@ -22,8 +22,8 @@
     2.4  VERSION = "0.1"
     2.5  
     2.6  from errors import *
     2.7 -from os import environ, rename
     2.8 -from os.path import abspath, exists, isfile, join, split
     2.9 +from os import environ, listdir, remove, rename
    2.10 +from os.path import abspath, exists, isdir, isfile, join, split
    2.11  from pyparser import error
    2.12  from subprocess import Popen, PIPE
    2.13  from time import time
    2.14 @@ -82,6 +82,17 @@
    2.15      else:
    2.16          return l, needed
    2.17  
    2.18 +def remove_all(dirname):
    2.19 +
    2.20 +    "Remove 'dirname' and its contents."
    2.21 +
    2.22 +    for filename in listdir(dirname):
    2.23 +        pathname = join(dirname, filename)
    2.24 +        if isdir(pathname):
    2.25 +            remove_all(pathname)
    2.26 +        else:
    2.27 +            remove(pathname)
    2.28 +
    2.29  # Main program.
    2.30  
    2.31  if __name__ == "__main__":
    2.32 @@ -98,21 +109,32 @@
    2.33  Compile the program whose principal file is given in place of <filename>.
    2.34  The following options may be specified:
    2.35  
    2.36 --c   Only partially compile the program; do not attempt to build or link it
    2.37 --E   Ignore environment variables affecting the module search path
    2.38 --g   Generate debugging information for the built executable
    2.39 --P   Show the module search path
    2.40 --q   Silence messages produced when building an executable
    2.41 --r   Reset (discard) cached program information; inspect the whole program again
    2.42 --t   Silence timing messages
    2.43 --tb  Provide a traceback for any internal errors (development only)
    2.44 --v   Report compiler activities in a verbose fashion (development only)
    2.45 +-c          Only partially compile the program; do not build or link it
    2.46 +--compile   Equivalent to -c
    2.47 +-E          Ignore environment variables affecting the module search path
    2.48 +--no-env    Equivalent to -E
    2.49 +-g          Generate debugging information for the built executable
    2.50 +--debug     Equivalent to -g
    2.51 +-P          Show the module search path
    2.52 +--show-path Equivalent to -P
    2.53 +-q          Silence messages produced when building an executable
    2.54 +--quiet     Equivalent to -q
    2.55 +-r          Reset (discard) cached information; inspect the whole program again
    2.56 +--reset     Equivalent to -r
    2.57 +-R          Reset (discard) all program details including translated code
    2.58 +--reset-all Equivalent to -R
    2.59 +-t          Silence timing messages
    2.60 +--no-timing Equivalent to -t
    2.61 +-tb         Provide a traceback for any internal errors (development only)
    2.62 +--traceback Equivalent to -tb
    2.63 +-v          Report compiler activities in a verbose fashion (development only)
    2.64 +--verbose   Equivalent to -v
    2.65  
    2.66  Some options may be followed by values, either immediately after the option
    2.67  (without any space between) or in the arguments that follow them:
    2.68  
    2.69 --o   Indicate the output executable name
    2.70 --W   Show warnings on the topics indicated
    2.71 +-o          Indicate the output executable name
    2.72 +-W          Show warnings on the topics indicated
    2.73  
    2.74  Currently, the following warnings are supported:
    2.75  
    2.76 @@ -152,6 +174,7 @@
    2.77      make = True
    2.78      make_verbose = True
    2.79      reset = False
    2.80 +    reset_all = False
    2.81      timings = True
    2.82      traceback = False
    2.83      verbose = False
    2.84 @@ -166,15 +189,16 @@
    2.85      needed = None
    2.86  
    2.87      for arg in args:
    2.88 -        if arg == "-c": make = False
    2.89 -        elif arg == "-E": ignore_env = True
    2.90 -        elif arg == "-g": debug = True
    2.91 -        elif arg == "-q": make_verbose = False
    2.92 -        elif arg == "-r": reset = True
    2.93 -        elif arg == "-t": timings = False
    2.94 -        elif arg == "-tb": traceback = True
    2.95 +        if arg in ("-c", "--compile"): make = False
    2.96 +        elif arg in ("-E", "--no-env"): ignore_env = True
    2.97 +        elif arg in ("-g", "--debug"): debug = True
    2.98 +        elif arg in ("-q", "--quiet"): make_verbose = False
    2.99 +        elif arg in ("-r", "--reset"): reset = True
   2.100 +        elif arg in ("-R", "--reset-all"): reset_all = True
   2.101 +        elif arg in ("-t", "--no-timing"): timings = False
   2.102 +        elif arg in ("-tb", "--traceback"): traceback = True
   2.103          elif arg.startswith("-o"): l, needed = start_arg_list(outputs, arg, "-o", 1)
   2.104 -        elif arg == "-v": verbose = True
   2.105 +        elif arg == ("-v", "--verbose"): verbose = True
   2.106          elif arg.startswith("-W"): l, needed = start_arg_list(warnings, arg, "-W", 1)
   2.107          else:
   2.108              l.append(arg)
   2.109 @@ -193,7 +217,7 @@
   2.110  
   2.111      # Show the module search path if requested.
   2.112  
   2.113 -    if "-P" in args:
   2.114 +    if "-P" in args or "--show-path" in args:
   2.115          for libdir in libdirs:
   2.116              print libdir
   2.117          sys.exit(0)
   2.118 @@ -227,6 +251,11 @@
   2.119      output_dir = join(datadir, "_output")
   2.120      generated_dir = join(datadir, "_generated")
   2.121  
   2.122 +    # Perform any full reset of the working data.
   2.123 +
   2.124 +    if reset_all:
   2.125 +        remove_all(datadir)
   2.126 +        
   2.127      # Load the program.
   2.128  
   2.129      try: