Changeset 8726 for src/Pugs/Run/Args.hs

Show
Ignore:
Timestamp:
01/17/06 14:08:41 (3 years ago)
Author:
audreyt
Message:

* Pugs.Run.Args: When the arg list parser encounters the script

file name, treat everything after it (even -options) as arguments.

So these two forms are now identical:

pugs foo.p6 --help
pugs foo.p6 -- --help

(t/pugsrun/12-script-args.t now passes because of this.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Run/Args.hs

    r6004 r8726  
    1919 
    2020-- | Command line argument parser for pugs. 
    21 module Pugs.Run.Args (canonicalArgs 
    22 , gatherArgs 
    23 , unpackOptions 
    24  
    25 ) 
    26 where 
     21module Pugs.Run.Args ( 
     22    canonicalArgs, 
     23    gatherArgs, 
     24    unpackOptions, 
     25) where 
    2726import Pugs.Internals 
    2827 
     
    5352 
    5453unpackOptions :: [String] -> [String] 
    55 unpackOptions [] = [] 
    56 unpackOptions (('-':[]):rest)  = ["-"] ++ unpackOptions rest 
    57 unpackOptions ("--":opts) = ["--"] ++ opts 
    58 unpackOptions (('-':opt):rest) = unpackOption opt ++ unpackOptions rest 
    59 unpackOptions (filename:rest) = filename : unpackOptions rest 
     54unpackOptions []                = [] 
     55unpackOptions (("-"):rest)      = ("-":unpackOptions rest) 
     56unpackOptions opts@("--":_)     = opts 
     57unpackOptions (('-':opt):arg:rest) 
     58    | takesArg opt              = unpackOption opt ++ (arg:unpackOptions rest) 
     59unpackOptions (('-':opt):rest)  = unpackOption opt ++ unpackOptions rest 
     60unpackOptions opts@[filename]   = opts 
     61unpackOptions (filename:rest)   = filename : "--" : unpackOptions rest 
     62 
     63takesArg :: String -> Bool 
     64takesArg xs     | xs `elem` withParam   = True 
     65takesArg (x:xs) | x `elem` composable   = takesArg xs 
     66takesArg _                              = False 
    6067 
    6168unpackOption :: String -> [String]