@@ -53,19 +53,26 @@ alexOpenFile file mode = do
53
53
-- `main' decodes the command line arguments and calls `alex'.
54
54
55
55
main :: IO ()
56
- main = do
57
- args <- getArgs
58
- case getOpt Permute argInfo args of
56
+ main = do
57
+ args <- getArgs
58
+ case getOpt Permute argInfo args of
59
59
(cli,_,[] ) | DumpHelp `elem` cli -> do
60
60
prog <- getProgramName
61
61
bye (usageInfo (usageHeader prog) argInfo)
62
62
(cli,_,[] ) | DumpVersion `elem` cli ->
63
63
bye copyright
64
+ (cli,_,[] ) | DumpNumericVersion `elem` cli ->
65
+ bye projectVersion
66
+ (cli,_,[] ) | OptVerbose `elem` cli ->
67
+ failure " Option '--verbose' not yet implemented"
64
68
(cli,[file],[] ) ->
65
69
runAlex cli file
66
- (_,_,errors) -> do
67
- prog <- getProgramName
68
- die (concat errors ++ usageInfo (usageHeader prog) argInfo)
70
+ (_,_,errors) ->
71
+ failure $ concat errors
72
+ where
73
+ failure err = do
74
+ prog <- getProgramName
75
+ die (err ++ usageInfo (usageHeader prog) argInfo)
69
76
70
77
projectVersion :: String
71
78
projectVersion = showVersion version
@@ -462,8 +469,10 @@ data CLIFlags
462
469
| OptTabSize String
463
470
| OptTemplateDir FilePath
464
471
| OptLatin1
472
+ | OptVerbose
465
473
| DumpHelp
466
474
| DumpVersion
475
+ | DumpNumericVersion
467
476
deriving Eq
468
477
469
478
argInfo :: [OptDescr CLIFlags ]
@@ -482,10 +491,14 @@ argInfo = [
482
491
" set tab size to be used in the generated lexer (default: 8)" ,
483
492
Option [' d' ] [" debug" ] (NoArg OptDebugParser )
484
493
" produce a debugging scanner" ,
494
+ Option [' v' ] [" verbose" ] (NoArg OptVerbose )
495
+ " be verbose (not yet implemented)" ,
485
496
Option [' ?' ] [" help" ] (NoArg DumpHelp )
486
497
" display this help and exit" ,
487
- Option [' V' , ' v ' ] [" version" ] (NoArg DumpVersion ) -- ToDo: -v is deprecated!
498
+ Option [' V' ] [" version" ] (NoArg DumpVersion )
488
499
" output version information and exit"
500
+ ,Option [] [" numeric-version" ] (NoArg DumpNumericVersion )
501
+ " output the version number and exit"
489
502
]
490
503
491
504
-- -----------------------------------------------------------------------------
0 commit comments