on master help sign in
add Obelisk.Command.Repl module, use optional --branch for 'ob init', & some misc. wording changes
commit049b92bcaaf4b00156c8d75c9261fb8b1e4ae735 authorhsloan <ishaqsloan@gmail.com> dateFri 5 Jan 2018, 13:07 (9 years ago) parent9098e6d
4 files changed+20−17
.gitignore−1 command/obelisk-command.cabal+1 command/src/Obelisk/Command.hs+6−16 command/src/Obelisk/Command/Repl.hs+13
.gitignore−1
@@ -6,5 +6,4 @@ result
66TAGS
77tags
88ctags
9−
109command/dist-newstyle
command/obelisk-command.cabal+1
@@ -26,6 +26,7 @@ library
2626 Obelisk.Command
2727 Obelisk.Command.Project
2828 Obelisk.Command.Thunk
29+ Obelisk.Command.Repl
2930 ghc-options: -Wall
3031
3132executable ob
command/src/Obelisk/Command.hs+6−16
@@ -3,19 +3,18 @@
33module Obelisk.Command where
44
55import Data.Monoid ((<>))
6−import Data.String (fromString)
7−import qualified Data.Text as Text
6+import Data.Maybe (fromMaybe)
87import Options.Applicative
98import System.Environment
109import System.IO
1110import System.Posix.Process
12−import System.Process
1311
1412import GitHub.Data.Name
1513import GitHub.Data.GitData
1614
1715import Obelisk.Command.Project
1816import Obelisk.Command.Thunk
17+import Obelisk.Command.Repl
1918
2019data Args = Args
2120 { _args_noHandOffPassed :: Bool
@@ -42,17 +41,17 @@ argsInfo = info (args <**> helper) $ mconcat
4241 ]
4342
4443data ObCommand
45− = ObCommand_Init (Name Branch)
44+ = ObCommand_Init (Maybe (Name Branch))
4645 | ObCommand_Dev
4746 | ObCommand_Thunk ThunkCommand
4847 | ObCommand_Repl FilePath
4948
5049obCommand :: Parser ObCommand
5150obCommand = hsubparser $ mconcat
52− [ command "init" $ info (ObCommand_Init <$> (strArgument (value "master"))) $ progDesc "Initialize an Obelisk project"
51+ [ command "init" $ info (ObCommand_Init <$> (optional (strOption (long "branch" <> metavar "BRANCH")))) $ progDesc "Initialize an Obelisk project"
5352 , command "dev" $ info (pure ObCommand_Dev) $ progDesc "Run the current project in development mode"
5453 , command "thunk" $ info (ObCommand_Thunk <$> thunkCommand) $ progDesc "Manipulate thunk directories"
55− , command "repl" $ info (ObCommand_Repl <$> (strArgument (action "directory"))) $ progDesc "Open a cabal repl"
54+ , command "repl" $ info (ObCommand_Repl <$> (strArgument (action "directory"))) $ progDesc "Open an interactive interpreter"
5655 ]
5756
5857data ThunkCommand
@@ -63,15 +62,6 @@ thunkCommand = hsubparser $ mconcat
6362 [ command "update" $ info (ThunkCommand_Update <$> some (strArgument (action "directory"))) $ progDesc "Update a thunk to the latest revision available"
6463 ]
6564
66−-- TODO modify the nix-shell arguments to recognize when the common dir's files have changed as well.
67−runRepl :: FilePath -> IO ()
68−runRepl dir = callProcess "nix-shell"
69− [ "-A"
70− , "shells.ghc"
71− , "--run"
72− , "\'cd " <> dir <> "; ghcid -W -c\"cabal new-repl exe:" <> dir <> "\"\'"
73− ]
74−
7565parserPrefs :: ParserPrefs
7666parserPrefs = defaultPrefs
7767 { prefShowHelpOnEmpty = True
@@ -102,7 +92,7 @@ main = do
10292
10393ob :: ObCommand -> IO ()
10494ob = \case
105− ObCommand_Init branch -> initProject "." branch
95+ ObCommand_Init branch -> initProject "." $ fromMaybe "master" branch
10696 ObCommand_Dev -> putStrLn "Dev!"
10797 ObCommand_Thunk tc -> case tc of
10898 ThunkCommand_Update thunks -> mapM_ updateThunkToLatest thunks
command/src/Obelisk/Command/Repl.hsnew file+13
@@ -0,0 +1,13 @@
1+module Obelisk.Command.Repl where
2+
3+import Data.Monoid ((<>))
4+import System.Process
5+
6+-- TODO modify the nix-shell arguments to recognize when the common dir's files have changed as well.
7+runRepl :: FilePath -> IO ()
8+runRepl dir = callProcess "nix-shell"
9+ [ "-A"
10+ , "shells.ghc"
11+ , "--run"
12+ , "\'cd " <> dir <> "; ghcid -W -c\"cabal new-repl exe:" <> dir <> "\"\'"
13+ ]