From 17b5bd08fbd878854d9ebdf017db163865ec9a7d Mon Sep 17 00:00:00 2001 From: Joaquin Florius Date: Sat, 22 Aug 2020 19:28:37 +0000 Subject: [PATCH] REadme and release --- CHANGELOG.md | 4 ++++ README.md | 15 +++++++++++++-- marble-os.cabal | 2 +- src/App.hs | 6 +++--- src/Args.hs | 9 +++++---- src/Configuration.hs | 2 +- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 533d0ec..b6a4ec1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Revision history for marble-os +## 0.1.2.0 -- 2020-08-16 + +* Added daemon support + ## 0.1.1.0 -- 2020-08-16 * Added multiline support (via `--lane`) diff --git a/README.md b/README.md index 675441b..43c2af5 100755 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ _A play on words with the phonetics of "marble os" and "marvelous"_ # Usage 1. Have a config file with the desired behavior -1. Run `marble` with the config file, piped to the program you want to run: `$ marble ./sample/calculator.mbl | ./sample/calculator.sh` +1. Run `marble` with the config file, piped to the program you want to run: `$ marble run ./sample/calculator.mbl | ./sample/calculator.sh` 1. ??? 1. Profit [![asciicast](https://asciinema.org/a/ffFLLTRD5ozZj0zqgDzS7rA7D.svg)](https://asciinema.org/a/ffFLLTRD5ozZj0zqgDzS7rA7D) -## Options +## Run Options | Option | Description | Example | Default value | |-----------|----------------------------------------------------|---------------|---------------| | repeat | Whether to repeat the sequence one it finishes | --repeat | false | @@ -29,6 +29,17 @@ E.g.: * `$ marble --tick=3m10s` - 3 minutes and 10 seconds _(this follows ISO 8601 duration spec. You can not jump units, and no spaces allowed)_ * `$ marble --tick=1500` - 1500 seconds = 25 minutes +## Distributed Run Options +`marble` can also be daemonized to run in-sync from multiple places. +To do so, start `marble` with `sync` rather than `run`. This will wait until the corresponding `marble` is launched (via `marble daemon start`). + +In addition to the [run options](#Run-Options), these are the additional distributed options +| Option | Description | Example | Default value | +|--------|-------------------------|--------------------|---------------| +| port | Port to run the daemon. | --port=1337 | 3000 | +| host | Host to run the daemon. | --host=192.168.3.3 | localhost | + + ## mbl syntax The `mbl` interpreter will parse the delimiter configured 👆 into "wait" and everything else into the output. If you need to output the characters in the delimiter, you can user another delimiter that does not crash, or escape the output string with `\`. diff --git a/marble-os.cabal b/marble-os.cabal index 21a86ef..bd842d1 100755 --- a/marble-os.cabal +++ b/marble-os.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 name: marble-os -version: 0.1.1.2 +version: 0.1.2.0 description: Run things at your own pace license: MIT license-file: LICENSE diff --git a/src/App.hs b/src/App.hs index 765a6d8..9cad0b6 100755 --- a/src/App.hs +++ b/src/App.hs @@ -102,7 +102,7 @@ main = do options (handleCommands state) else pure () - res <- D.runClient (T.unpack $ C.unHost host) port (command) + res <- D.runClient (C.unHost host) port (command) print (res :: Maybe Response) where command :: Command @@ -111,7 +111,7 @@ main = do C.Start -> TriggerStart C.Sync (C.SyncConfiguration config' remote) -> do let port = C.port remote - let host = (T.unpack $ C.unHost $ C.host remote) + let host = (C.unHost $ C.host remote) let options = def { D.daemonPort = port, D.printOnDaemonStarted = False } -- TODO duplicated! if host == def then do @@ -125,5 +125,5 @@ main = do res <- D.runClient host port (Hello mbl) case res of Just (Start newMbl) -> interpret config' newMbl - _ -> fail "TODO" + _ -> fail $ show res diff --git a/src/Args.hs b/src/Args.hs index 4d5ea60..ec97385 100644 --- a/src/Args.hs +++ b/src/Args.hs @@ -23,8 +23,8 @@ import Options.Applicative ( Parser , auto , subparser , command + , str ) - import qualified Duration as D import qualified Data.String as S import qualified Configuration as C @@ -42,15 +42,16 @@ remote = <> showDefault <> value 3000 ) - <*> option - auto + <*> (C.Host <$> option + str ( long "host" <> short 'h' <> help "Host to run the daemon." <> metavar "HOST" <> showDefault - <> value def + <> (value $ C.unHost def) ) + ) daemon :: Parser C.DaemonConfiguration daemon = C.DaemonConfiguration <$> daemonSubCmd <*> remote diff --git a/src/Configuration.hs b/src/Configuration.hs index c9038e3..d4bdf84 100644 --- a/src/Configuration.hs +++ b/src/Configuration.hs @@ -25,7 +25,7 @@ data Remote = Remote { port :: Port , host :: Host } data Configuration = Run RunConfiguration | Sync SyncConfiguration | Daemon DaemonConfiguration -newtype Host = Host { unHost :: T.Text } deriving (Show, Eq, Read) +newtype Host = Host { unHost :: String } deriving (Show, Eq, Read) type Port = Int