Skip to content

Commit 046e02b

Browse files
committed
[ new ] Command line option for printing version info
1 parent acfe0db commit 046e02b

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## v0.2.7.0.1.5 - 2024-12-18
8+
9+
### Added
10+
- New command line option `--version` and `-V` for printing version information.
11+
712
## v0.2.7.0.1.4 - 2024-12-6
813

914
### Changed

app/Main.hs

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ main = do
3232
options <- getOptionsFromArgv
3333
if optHelp options
3434
then putStrLn usageMessage
35-
else do
36-
_ <- run options
37-
-- _ <- run
38-
return ()
35+
else
36+
if optVersion options
37+
then putStrLn versionString
38+
else do
39+
_ <- run options
40+
-- _ <- run
41+
return ()

package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: agda-language-server
2-
version: 0.2.7.0.1.4
2+
version: 0.2.7.0.1.5
33
github: "banacorn/agda-language-server"
44
license: MIT
55
author: "Ting-Gian LUA"

src/Options.hs

+22-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
module Options
55
( Options (..),
66
getOptionsFromArgv,
7+
versionString,
78
usageMessage,
89
Config (..),
910
initConfig,
@@ -37,12 +38,13 @@ usageMessage = usageInfo usage options ++ usageAboutAgdaOptions
3738
data Options = Options
3839
{ optViaTCP :: Maybe Int,
3940
optRawAgdaOptions :: [String],
40-
optHelp :: Bool
41+
optHelp :: Bool,
42+
optVersion :: Bool
4143
}
4244

4345
defaultOptions :: Options
4446
defaultOptions =
45-
Options {optViaTCP = Nothing, optRawAgdaOptions = [], optHelp = False}
47+
Options {optViaTCP = Nothing, optRawAgdaOptions = [], optHelp = False, optVersion = False}
4648

4749
options :: [OptDescr (Options -> Options)]
4850
options =
@@ -61,21 +63,32 @@ options =
6163
)
6264
"PORT"
6365
)
64-
"talk with the editor via TCP port (4096 as default)"
66+
"talk with the editor via TCP port (4096 as default)",
67+
Option
68+
['V']
69+
["version"]
70+
(NoArg (\opts -> opts {optVersion = True}))
71+
"print version information and exit"
6572
]
6673

67-
usage :: String
68-
usage =
74+
versionNumber :: Int
75+
versionNumber = 5
76+
77+
versionString :: String
78+
versionString =
6979
#if MIN_VERSION_Agda(2,7,0)
70-
"Agda v2.7.0.1 Language Server v4\nUsage: als [Options...]\n"
80+
"Agda v2.7.0.1 Language Server v" <> show versionNumber
7181
#elif MIN_VERSION_Agda(2,6,4)
72-
"Agda v2.6.4.3 Language Server v4\nUsage: als [Options...]\n"
82+
"Agda v2.6.4.3 Language Server v" <> show versionNumber
7383
#elif MIN_VERSION_Agda(2,6,3)
74-
"Agda v2.6.3 Language Server v4\nUsage: als [Options...]\n"
84+
"Agda v2.6.3 Language Server v" <> show versionNumber
7585
#else
76-
"Unsupported Agda version\n"
86+
error "Unsupported Agda version"
7787
#endif
7888

89+
usage :: String
90+
usage = versionString <> "\nUsage: als [Options...]\n"
91+
7992
usageAboutAgdaOptions :: String
8093
usageAboutAgdaOptions = "\n +AGDA [Options for Agda ...] -AGDA\n To pass command line options to Agda, put them in between '+AGDA' and '-AGDA'\n For example:\n als -p=3000 +AGDA --cubical -AGDA\n If you are using agda-mode on VS Code, put them in the Settings at:\n agdaMode.connection.commandLineOptions\n"
8194

0 commit comments

Comments
 (0)