Changeset 14908 for src/Pugs/Help.hs

Show
Ignore:
Timestamp:
12/17/06 17:28:25 (2 years ago)
Author:
wolverian
Message:

r4@pupu: wolverian | 2006-12-17 18:09:46 +0200
Small refactoring to Help.hs, and move the backends line up, spotted by DebolazX++

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Help.hs

    r14459 r14908  
    1717import Pugs.Version 
    1818import Pugs.CodeGen (backends) 
    19 import Data.List (sort) 
     19import Data.List (sort, intersperse) 
    2020 
    2121printInteractiveHelp :: IO () 
    2222printInteractiveHelp 
    23    = do putStrLn "Commands available from the prompt:" 
    24         putStrLn ":h              = show this help message" 
    25         putStrLn ":q              = quit" 
    26         putStrLn ":r              = reset the evaluation environment" 
    27         putStrLn ":l <filename>   = load a pugs file" 
    28         putStrLn ":d <exp>        = show syntax tree of an expression" 
    29         putStrLn ":D <exp>        = show raw syntax tree of an expression" 
    30         putStrLn ":e <exp>        = run a command, and ugly-print the result" 
    31         putStrLn ":er <exp>       = same, in a pristine environment" 
    32         putStrLn ":E <exp>        = same, but evaluate in small steps" 
    33         putStrLn ":ER <exp>       = same, in a pristine environment" 
    34         putStrLn "<exp>           = run a command" 
     23   = putStrLn $ unlines 
     24        [ "Commands available from the prompt:" 
     25        , ":h              = show this help message" 
     26        , ":q              = quit" 
     27        , ":r              = reset the evaluation environment" 
     28        , ":l <filename>   = load a pugs file" 
     29        , ":d <exp>        = show syntax tree of an expression" 
     30        , ":D <exp>        = show raw syntax tree of an expression" 
     31        , ":e <exp>        = run a command, and ugly-print the result" 
     32        , ":er <exp>       = same, in a pristine environment" 
     33        , ":E <exp>        = same, but evaluate in small steps" 
     34        , ":ER <exp>       = same, in a pristine environment" 
     35        , "<exp>           = run a command" 
     36        ] 
    3537 
    3638{- FIXME: Somebody with more UI skillz should make this nicer -} 
    3739printCommandLineHelp :: IO () 
    3840printCommandLineHelp 
    39    = do putStrLn "Usage: pugs [switches] [programfile] [arguments]" 
    40         putStrLn "Command-line flags:" 
    41         putStrLn "-e program       one line of program (several -e's allowed, omit programfile)" 
    42         putStrLn "-n               wrap the -e fragments in a 'while(=<>){...}' loop" 
    43         putStrLn "-p               wrap the -e fragments in a 'while(=<>){...;say}' loop" 
    44         putStrLn "-c               parse the file or -e, but do not run it" 
    45         putStrLn "-d               run the program with debug tracing" 
    46         putStrLn "-Bbackend        execute using the compiler backend" 
    47         putStrLn "-Cbackend        compile using the compiler backend" 
    48         putStrLn "-Mmodule         execute 'use module' before running the program" 
    49         putStrLn "-Ipath           add path to module search paths in @*INC" 
    50         putStrLn ("                 (valid backends are: " ++ backendsStr ++ ")") 
    51         putStrLn "-h or --help     give this message" 
    52         putStrLn "-V               long configuration information & version" 
    53         putStrLn "-V:item          short configuration information for item" 
    54         putStrLn "-v or --version  version" 
    55         putStrLn "-l and -w are ignored for compatibility with Perl 5" 
    56         putStrLn "See documentation of pugs::run for more help." 
     41   = putStrLn $ unlines 
     42        [ "Usage: pugs [switches] [programfile] [arguments]" 
     43        , "Command-line flags:" 
     44        , "-e program       one line of program (several -e's allowed, omit programfile)" 
     45        , "-n               wrap the -e fragments in a 'while(=<>){...}' loop" 
     46        , "-p               wrap the -e fragments in a 'while(=<>){...;say}' loop" 
     47        , "-c               parse the file or -e, but do not run it" 
     48        , "-d               run the program with debug tracing" 
     49        , "-Bbackend        execute using the compiler backend" 
     50        , "-Cbackend        compile using the compiler backend" 
     51        , "                 (valid backends are: " ++ backendsStr ++ ")" 
     52        , "-Mmodule         execute 'use module' before running the program" 
     53        , "-Ipath           add path to module search paths in @*INC" 
     54        , "-h or --help     give this message" 
     55        , "-V               long configuration information & version" 
     56        , "-V:item          short configuration information for item" 
     57        , "-v or --version  version" 
     58        , "-l and -w are ignored for compatibility with Perl 5" 
     59        , "See documentation of pugs::run for more help." 
     60        ] 
    5761    where 
    58     backendsStr = foldr1 addComma $ sort ("JS":backends) 
    59     addComma w s = w ++ (',':' ':s) 
     62    backendsStr = concat . intersperse ", " $ sort ("JS":backends) 
    6063 
    6164versionFill :: Int -> String