Commit e0b3b2ac authored by Bas Lijnse's avatar Bas Lijnse

Merge branch 'add-showInstructions-and-quiet-cli-option' into 'master'

Add showInstructions to EngineOptions with -q/--quiet command-line option

See merge request !342
parents 957785c7 3ab416f1
Pipeline #31668 passed with stage
in 7 minutes and 1 second
...@@ -57,24 +57,25 @@ instance Startable [StartableTask] ...@@ -57,24 +57,25 @@ instance Startable [StartableTask]
instance Startable (a,b) | Startable a & Startable b instance Startable (a,b) | Startable a & Startable b
:: EngineOptions = :: EngineOptions =
{ appName :: String { appName :: !String
, appPath :: FilePath // Location of the application's executable , appPath :: !FilePath //* Location of the application's executable
, appVersion :: String , appVersion :: !String
, serverPort :: Int , serverPort :: !Int
, serverUrl :: String , serverUrl :: !String
, allowedHosts :: [String] // Only allow connections from these hosts (default ["127.0.0.1"]) , allowedHosts :: ![String] //* Only allow connections from these hosts (default ["127.0.0.1"])
, keepaliveTime :: Timespec , keepaliveTime :: !Timespec
, sessionTime :: Timespec , sessionTime :: !Timespec
, persistTasks :: Bool , persistTasks :: !Bool
, autoLayout :: Bool , autoLayout :: !Bool
, maxEvents :: Int , maxEvents :: !Int
, timeout :: Maybe Int // The timeout , timeout :: !Maybe Int //* The timeout
, distributed :: Bool , distributed :: !Bool
, sdsPort :: Int , sdsPort :: !Int
, webDirPath :: FilePath // Location of public files that are served by the iTask webserver , webDirPath :: !FilePath //* Location of public files that are served by the iTask webserver
, storeDirPath :: FilePath // Location of the application's persistent data files , storeDirPath :: !FilePath //* Location of the application's persistent data files
, tempDirPath :: FilePath // Location for temporary files used in tasks , tempDirPath :: !FilePath //* Location for temporary files used in tasks
, byteCodePath :: FilePath // Location of the application's bytecode , byteCodePath :: !FilePath //* Location of the application's bytecode
, showInstructions :: !Bool //* Whether instructions to open the browser should be shown
} }
derive class iTask EngineOptions derive class iTask EngineOptions
......
...@@ -24,6 +24,7 @@ import iTasks.Internal.Util ...@@ -24,6 +24,7 @@ import iTasks.Internal.Util
import iTasks.SDS.Sources.System import iTasks.SDS.Sources.System
import iTasks.WF.Combinators.Common import iTasks.WF.Combinators.Common
import iTasks.WF.Definition import iTasks.WF.Definition
import iTasks.WF.Tasks.Core
import iTasks.WF.Tasks.SDS import iTasks.WF.Tasks.SDS
import iTasks.WF.Tasks.System import iTasks.WF.Tasks.System
import iTasks.WF.Derives import iTasks.WF.Derives
...@@ -151,6 +152,8 @@ where ...@@ -151,6 +152,8 @@ where
"Enable distributed mode (populate the symbols share)" "Enable distributed mode (populate the symbols share)"
, Option ['s'] ["sdsPort"] (ReqArg (\p->fmap \o->{o & sdsPort=toInt p}) "SDSPORT") , Option ['s'] ["sdsPort"] (ReqArg (\p->fmap \o->{o & sdsPort=toInt p}) "SDSPORT")
("Specify the SDS port (default: " +++ toString defaults.sdsPort +++ ")") ("Specify the SDS port (default: " +++ toString defaults.sdsPort +++ ")")
, Option ['q'] ["quiet"] (NoArg (fmap \o->{o & showInstructions=False}))
"Don't show instructions to open the browser"
] ]
onStartup :: (Task a) -> StartableTask | iTask a onStartup :: (Task a) -> StartableTask | iTask a
...@@ -189,10 +192,11 @@ instance Startable (a,b) | Startable a & Startable b ...@@ -189,10 +192,11 @@ instance Startable (a,b) | Startable a & Startable b
where where
toStartable (x,y) = toStartable x ++ toStartable y toStartable (x,y) = toStartable x ++ toStartable y
viewWebServerInstructions :: Task String viewWebServerInstructions :: Task ()
viewWebServerInstructions viewWebServerInstructions
= get applicationOptions = get applicationOptions
>>- \{EngineOptions|appName,serverPort} -> >>- \{EngineOptions|appName,serverPort,showInstructions}
| showInstructions ->
traceValue (join OS_NEWLINE traceValue (join OS_NEWLINE
["*** " +++ appName +++ " HTTP server ***" ["*** " +++ appName +++ " HTTP server ***"
,"" ,""
...@@ -200,7 +204,8 @@ viewWebServerInstructions ...@@ -200,7 +204,8 @@ viewWebServerInstructions
if (serverPort == 80) if (serverPort == 80)
"/" "/"
(":" +++ toString serverPort +++ "/") (":" +++ toString serverPort +++ "/")
]) ]) @! ()
| otherwise -> treturn ()
defaultEngineOptions :: !*World -> (!EngineOptions,!*World) defaultEngineOptions :: !*World -> (!EngineOptions,!*World)
defaultEngineOptions world defaultEngineOptions world
...@@ -209,24 +214,25 @@ defaultEngineOptions world ...@@ -209,24 +214,25 @@ defaultEngineOptions world
# appDir = takeDirectory appPath # appDir = takeDirectory appPath
# appName = (if (takeExtension appPath == "exe") dropExtension id o dropDirectory) appPath # appName = (if (takeExtension appPath == "exe") dropExtension id o dropDirectory) appPath
# options = # options =
{ appName = appName { appName = appName
, appPath = appPath , appPath = appPath
, appVersion = appVersion , appVersion = appVersion
, serverPort = IF_POSIX_OR_WINDOWS 8080 80 , serverPort = IF_POSIX_OR_WINDOWS 8080 80
, serverUrl = "http://localhost/" , serverUrl = "http://localhost/"
, allowedHosts = ["127.0.0.1"] , allowedHosts = ["127.0.0.1"]
, keepaliveTime = {tv_sec=300,tv_nsec=0} // 5 minutes , keepaliveTime = {tv_sec=300,tv_nsec=0} // 5 minutes
, sessionTime = {tv_sec=60,tv_nsec=0} // 1 minute, (the client pings every 10 seconds by default) , sessionTime = {tv_sec=60,tv_nsec=0} // 1 minute, (the client pings every 10 seconds by default)
, persistTasks = False , persistTasks = False
, autoLayout = True , autoLayout = True
, distributed = False , distributed = False
, maxEvents = 5 , maxEvents = 5
, sdsPort = 9090 , sdsPort = 9090
, timeout = Nothing//Just 500 , timeout = Nothing//Just 500
, webDirPath = appDir </> appName +++ "-www" , webDirPath = appDir </> appName +++ "-www"
, storeDirPath = appDir </> appName +++ "-data" </> "stores" , storeDirPath = appDir </> appName +++ "-data" </> "stores"
, tempDirPath = appDir </> appName +++ "-data" </> "tmp" , tempDirPath = appDir </> appName +++ "-data" </> "tmp"
, byteCodePath = appDir </> appName +++ ".bc" , byteCodePath = appDir </> appName +++ ".bc"
, showInstructions = True
} }
= (options,world) = (options,world)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment