Skip to content

Commit 48f6cfb

Browse files
committed
Add option --numeric-version and rededicate -v to future --verbose
Closes #250.
1 parent ff4832e commit 48f6cfb

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
* Add option `--numeric-version`.
4+
* Remove deprecated `-v` as alias for `--version`.
5+
* Add `-v` as placeholder for a future `--verbose` option.
6+
17
## Changes in 3.4.0.1
28

39
* Address new `x-partial` warning of GHC 9.8.

src/Main.hs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,26 @@ alexOpenFile file mode = do
5353
-- `main' decodes the command line arguments and calls `alex'.
5454

5555
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
5959
(cli,_,[]) | DumpHelp `elem` cli -> do
6060
prog <- getProgramName
6161
bye (usageInfo (usageHeader prog) argInfo)
6262
(cli,_,[]) | DumpVersion `elem` cli ->
6363
bye copyright
64+
(cli,_,[]) | DumpNumericVersion `elem` cli ->
65+
bye projectVersion
66+
(cli,_,[]) | OptVerbose `elem` cli ->
67+
failure "Option '--verbose' not yet implemented"
6468
(cli,[file],[]) ->
6569
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)
6976

7077
projectVersion :: String
7178
projectVersion = showVersion version
@@ -462,8 +469,10 @@ data CLIFlags
462469
| OptTabSize String
463470
| OptTemplateDir FilePath
464471
| OptLatin1
472+
| OptVerbose
465473
| DumpHelp
466474
| DumpVersion
475+
| DumpNumericVersion
467476
deriving Eq
468477

469478
argInfo :: [OptDescr CLIFlags]
@@ -482,10 +491,14 @@ argInfo = [
482491
"set tab size to be used in the generated lexer (default: 8)",
483492
Option ['d'] ["debug"] (NoArg OptDebugParser)
484493
"produce a debugging scanner",
494+
Option ['v'] ["verbose"] (NoArg OptVerbose)
495+
"be verbose (not yet implemented)",
485496
Option ['?'] ["help"] (NoArg DumpHelp)
486497
"display this help and exit",
487-
Option ['V','v'] ["version"] (NoArg DumpVersion) -- ToDo: -v is deprecated!
498+
Option ['V'] ["version"] (NoArg DumpVersion)
488499
"output version information and exit"
500+
,Option [] ["numeric-version"] (NoArg DumpNumericVersion)
501+
"output the version number and exit"
489502
]
490503

491504
-- -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)