Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option --numeric-version and rededicate -v to future --verbose #251

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

* Add option `--numeric-version`.
* Remove deprecated `-v` as alias for `--version`.
* Add `-v` as placeholder for a future `--verbose` option.

## Changes in 3.4.0.1

* Address new `x-partial` warning of GHC 9.8.
Expand Down
27 changes: 20 additions & 7 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,26 @@ alexOpenFile file mode = do
-- `main' decodes the command line arguments and calls `alex'.

main:: IO ()
main = do
args <- getArgs
case getOpt Permute argInfo args of
main = do
args <- getArgs
case getOpt Permute argInfo args of
(cli,_,[]) | DumpHelp `elem` cli -> do
prog <- getProgramName
bye (usageInfo (usageHeader prog) argInfo)
(cli,_,[]) | DumpVersion `elem` cli ->
bye copyright
(cli,_,[]) | DumpNumericVersion `elem` cli ->
bye projectVersion
(cli,_,[]) | OptVerbose `elem` cli ->
failure "Option '--verbose' not yet implemented"
(cli,[file],[]) ->
runAlex cli file
(_,_,errors) -> do
prog <- getProgramName
die (concat errors ++ usageInfo (usageHeader prog) argInfo)
(_,_,errors) ->
failure $ concat errors
where
failure err = do
prog <- getProgramName
die (err ++ usageInfo (usageHeader prog) argInfo)

projectVersion :: String
projectVersion = showVersion version
Expand Down Expand Up @@ -462,8 +469,10 @@ data CLIFlags
| OptTabSize String
| OptTemplateDir FilePath
| OptLatin1
| OptVerbose
| DumpHelp
| DumpVersion
| DumpNumericVersion
deriving Eq

argInfo :: [OptDescr CLIFlags]
Expand All @@ -482,10 +491,14 @@ argInfo = [
"set tab size to be used in the generated lexer (default: 8)",
Option ['d'] ["debug"] (NoArg OptDebugParser)
"produce a debugging scanner",
Option ['v'] ["verbose"] (NoArg OptVerbose)
"be verbose (not yet implemented)",
Option ['?'] ["help"] (NoArg DumpHelp)
"display this help and exit",
Option ['V','v'] ["version"] (NoArg DumpVersion) -- ToDo: -v is deprecated!
Option ['V'] ["version"] (NoArg DumpVersion)
"output version information and exit"
,Option [] ["numeric-version"] (NoArg DumpNumericVersion)
"output the version number and exit"
]

-- -----------------------------------------------------------------------------
Expand Down