Skip to content

Commit

Permalink
[ new ] Command line option for printing version info
Browse files Browse the repository at this point in the history
  • Loading branch information
banacorn committed Dec 18, 2024
1 parent acfe0db commit 046e02b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

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

## v0.2.7.0.1.5 - 2024-12-18

### Added
- New command line option `--version` and `-V` for printing version information.

## v0.2.7.0.1.4 - 2024-12-6

### Changed
Expand Down
11 changes: 7 additions & 4 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ main = do
options <- getOptionsFromArgv
if optHelp options
then putStrLn usageMessage
else do
_ <- run options
-- _ <- run
return ()
else
if optVersion options
then putStrLn versionString
else do
_ <- run options
-- _ <- run
return ()
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: agda-language-server
version: 0.2.7.0.1.4
version: 0.2.7.0.1.5
github: "banacorn/agda-language-server"
license: MIT
author: "Ting-Gian LUA"
Expand Down
31 changes: 22 additions & 9 deletions src/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Options
( Options (..),
getOptionsFromArgv,
versionString,
usageMessage,
Config (..),
initConfig,
Expand Down Expand Up @@ -37,12 +38,13 @@ usageMessage = usageInfo usage options ++ usageAboutAgdaOptions
data Options = Options
{ optViaTCP :: Maybe Int,
optRawAgdaOptions :: [String],
optHelp :: Bool
optHelp :: Bool,
optVersion :: Bool
}

defaultOptions :: Options
defaultOptions =
Options {optViaTCP = Nothing, optRawAgdaOptions = [], optHelp = False}
Options {optViaTCP = Nothing, optRawAgdaOptions = [], optHelp = False, optVersion = False}

options :: [OptDescr (Options -> Options)]
options =
Expand All @@ -61,21 +63,32 @@ options =
)
"PORT"
)
"talk with the editor via TCP port (4096 as default)"
"talk with the editor via TCP port (4096 as default)",
Option
['V']
["version"]
(NoArg (\opts -> opts {optVersion = True}))
"print version information and exit"
]

usage :: String
usage =
versionNumber :: Int
versionNumber = 5

versionString :: String
versionString =
#if MIN_VERSION_Agda(2,7,0)
"Agda v2.7.0.1 Language Server v4\nUsage: als [Options...]\n"
"Agda v2.7.0.1 Language Server v" <> show versionNumber
#elif MIN_VERSION_Agda(2,6,4)
"Agda v2.6.4.3 Language Server v4\nUsage: als [Options...]\n"
"Agda v2.6.4.3 Language Server v" <> show versionNumber
#elif MIN_VERSION_Agda(2,6,3)
"Agda v2.6.3 Language Server v4\nUsage: als [Options...]\n"
"Agda v2.6.3 Language Server v" <> show versionNumber
#else
"Unsupported Agda version\n"
error "Unsupported Agda version"
#endif

usage :: String
usage = versionString <> "\nUsage: als [Options...]\n"

usageAboutAgdaOptions :: String
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"

Expand Down

0 comments on commit 046e02b

Please sign in to comment.