From 77e6321e8c732b9998018a61b37cfb78c6bbc88e Mon Sep 17 00:00:00 2001 From: Sebastian Graf Date: Tue, 24 Sep 2024 13:39:21 +0200 Subject: [PATCH] Implement --numeric-version (#301) Fixes #301. --- ChangeLog.md | 4 ++++ app/Main.lhs | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5c07a7a7..84c3350d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Revision history for Happy +## 2.1 + +* Added `--numeric-version` CLI flag. + ## 2.0.2 The 2.0.1 release in turn exposed two more regressions: diff --git a/app/Main.lhs b/app/Main.lhs index a5fecd24..9f43b7bd 100644 --- a/app/Main.lhs +++ b/app/Main.lhs @@ -48,6 +48,8 @@ Read and parse the CLI arguments. > case getOpt Permute argInfo (constArgs ++ args) of > (cli,_,[]) | DumpVersion `elem` cli -> > bye copyright +> (cli,_,[]) | DumpNumericVersion `elem` cli -> +> bye projectVersion > (cli,_,[]) | DumpHelp `elem` cli -> do > prog <- getProgramName > bye (usageInfo (usageHeader prog) argInfo) @@ -307,6 +309,7 @@ The command line arguments. > | DumpGoto > | DumpLA > | DumpVersion +> | DumpNumericVersion > | DumpHelp > | OptInfoFile (Maybe String) > | OptPrettyFile (Maybe String) @@ -355,11 +358,12 @@ The command line arguments. > Option ['?'] ["help"] (NoArg DumpHelp) > "display this help and exit", > Option ['V','v'] ["version"] (NoArg DumpVersion) -- ToDo: -v is deprecated -> "output version information and exit" +> "output version information and exit", +> Option [] ["numeric-version"] (NoArg DumpNumericVersion) -- ToDo: -v is deprecated +> "output the version number and exit", Various debugging/dumping options... -> , > Option [] ["ddump-mangle"] (NoArg DumpMangle) > "Dump mangled input", > Option [] ["ddump-lr0"] (NoArg DumpLR0) @@ -424,6 +428,9 @@ Extract various command-line options. ------------------------------------------------------------------------------ +> projectVersion :: String +> projectVersion = showVersion version + > copyright :: String > copyright = unlines [ > "Happy Version " ++ showVersion version ++ " Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow","",