Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
625a2a2f
Commit
625a2a2f
authored
Feb 13, 2016
by
Sumit Sahrawat
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #639 from nicluo/master
Support --version, -V in CLI
parents
d1c84ee2
ed3b892e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
Main.hs
main/Main.hs
+15
-3
Flags.hs
src/IHaskell/Flags.hs
+8
-7
No files found.
main/Main.hs
View file @
625a2a2f
...
...
@@ -28,6 +28,7 @@ import System.Posix.Signals
import
qualified
Data.Map
as
Map
import
qualified
Data.Text.Encoding
as
E
import
Data.List
(
break
,
last
)
import
Data.Version
(
showVersion
)
-- IHaskell imports.
import
IHaskell.Convert
(
convert
)
...
...
@@ -46,6 +47,9 @@ import IHaskell.IPython.Types
import
qualified
IHaskell.IPython.Message.UUID
as
UUID
import
qualified
IHaskell.IPython.Stdin
as
Stdin
-- Cabal imports.
import
Paths_ihaskell
(
version
)
-- GHC API imports.
import
GHC
hiding
(
extensions
,
language
)
...
...
@@ -69,7 +73,7 @@ main = do
Right
args
->
ihaskell
args
ihaskell
::
Args
->
IO
()
ihaskell
(
Args
(
Show
Help
help
)
_
)
=
putStrLn
help
ihaskell
(
Args
(
Show
Default
helpStr
)
args
)
=
showDefault
helpStr
args
ihaskell
(
Args
ConvertLhs
args
)
=
showingHelp
ConvertLhs
args
$
convert
args
ihaskell
(
Args
InstallKernelSpec
args
)
=
showingHelp
InstallKernelSpec
args
$
do
let
kernelSpecOpts
=
parseKernelArgs
args
...
...
@@ -82,6 +86,14 @@ ihaskell a@(Args (Kernel Nothing) _) = do
hPutStrLn
stderr
"This may be a bug!"
hPrint
stderr
a
showDefault
::
String
->
[
Argument
]
->
IO
()
showDefault
helpStr
flags
=
case
find
(
==
Version
)
flags
of
Just
_
->
putStrLn
(
showVersion
version
)
Nothing
->
putStrLn
helpStr
showingHelp
::
IHaskellMode
->
[
Argument
]
->
IO
()
->
IO
()
showingHelp
mode
flags
act
=
case
find
(
==
Help
)
flags
of
...
...
@@ -240,9 +252,9 @@ replyTo _ KernelInfoRequest{} replyHeader state =
(
state
,
KernelInfoReply
{
header
=
replyHeader
,
protocolVersion
=
"5.0"
,
banner
=
"IHaskell "
++
VERSION_ipython_kernel
++
" GHC "
++
VERSION_ghc
,
banner
=
"IHaskell "
++
(
showVersion
version
)
++
" GHC "
++
VERSION_ghc
,
implementation
=
"IHaskell"
,
implementationVersion
=
VERSION_ipython_kernel
,
implementationVersion
=
showVersion
version
,
languageInfo
=
LanguageInfo
{
languageName
=
"haskell"
,
languageVersion
=
VERSION_ghc
...
...
src/IHaskell/Flags.hs
View file @
625a2a2f
...
...
@@ -32,6 +32,7 @@ data Argument = ConfFile String -- ^ A file with commands to load at startup
|
GhcLibDir
String
-- ^ Where to find the GHC libraries.
|
KernelDebug
-- ^ Spew debugging output from the kernel.
|
Help
-- ^ Display help text.
|
Version
-- ^ Display version text.
|
ConvertFrom
String
|
ConvertTo
String
|
ConvertFromFormat
NotebookFormat
...
...
@@ -57,7 +58,7 @@ data NotebookFormat = LhsMarkdown
deriving
(
Eq
,
Show
)
-- Which mode IHaskell is being invoked in.
data
IHaskellMode
=
Show
Help
String
data
IHaskellMode
=
Show
Default
String
|
InstallKernelSpec
|
ConvertLhs
|
Kernel
(
Maybe
String
)
...
...
@@ -70,9 +71,7 @@ parseFlags flags =
in
case
modeIndex
of
Nothing
->
-- Treat no mode as 'console'.
if
"--help"
`
elem
`
flags
then
Left
$
showText
(
Wrap
100
)
$
helpText
[]
HelpFormatAll
ihaskellArgs
else
process
ihaskellArgs
flags
process
ihaskellArgs
flags
Just
0
->
process
ihaskellArgs
flags
Just
idx
->
...
...
@@ -177,10 +176,12 @@ lhsStyleTex = LhsStyle "" "" "\\begin{code}" "\\end{code}" "\\begin{verbatim}" "
ihaskellArgs
::
Mode
Args
ihaskellArgs
=
let
descr
=
"Haskell for Interactive Computing."
let
noMode
=
mode
"IHaskell"
defaultReport
descr
noArgs
[
helpFlag
,
versionFlag
]
defaultReport
=
Args
(
ShowDefault
helpStr
)
[]
descr
=
"Haskell for Interactive Computing."
helpFlag
=
flagHelpSimple
(
add
Help
)
versionFlag
=
flagVersion
(
add
Version
)
helpStr
=
showText
(
Wrap
100
)
$
helpText
[]
HelpFormatAll
ihaskellArgs
onlyHelp
=
[
flagHelpSimple
(
add
Help
)]
noMode
=
mode
"IHaskell"
(
Args
(
ShowHelp
helpStr
)
[]
)
descr
noArgs
onlyHelp
in
noMode
{
modeGroupModes
=
toGroup
allModes
}
where
add
flag
(
Args
mode
flags
)
=
Args
mode
$
flag
:
flags
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment