-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
dev anoma print-config
command (#3260)
E.g. ``` juvix dev anoma start juvix dev anoma print-config ``` output: ``` nodeid: '130225697' port: 45367 url: localhost ```
- Loading branch information
1 parent
a4faa31
commit b386fbc
Showing
7 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
module Commands.Dev.Anoma.Client where | ||
module Commands.Dev.Anoma.Client | ||
( module Commands.Dev.Anoma.Client, | ||
module Anoma.Client.Config, | ||
) | ||
where | ||
|
||
import Anoma.Client.Config | ||
import Anoma.Effect.Base | ||
import Commands.Base | ||
import Data.Foldable.Extra qualified as E | ||
import Juvix.Prelude.Posix | ||
|
||
isClientRunning :: (Members '[Files, EmbedIO, Error SimpleError, Logger] r) => ClientConfig -> Sem r Bool | ||
isClientRunning :: (Members '[Files, EmbedIO, Error SimpleError] r) => ClientConfig -> Sem r Bool | ||
isClientRunning c = | ||
runAnomaWithClient | ||
(c ^. clientConfigHost) | ||
(catchError @SimpleError (anomaListMethods >> return True) (\_ _ -> return False)) | ||
|
||
checkClientRunning :: (Members '[Logger, Files, EmbedIO, Error SimpleError] r) => Sem r (Maybe ClientConfig) | ||
checkClientRunning :: (Members '[Files, EmbedIO, Error SimpleError] r) => Sem r (Maybe ClientConfig) | ||
checkClientRunning = do | ||
mconfig <- readConfig | ||
E.findM isClientRunning mconfig | ||
|
||
getClientConfig :: | ||
(Members '[Files, EmbedIO, Error SimpleError] r) => | ||
Sem r ClientConfig | ||
getClientConfig = fromMaybeM (throw @SimpleError "The Anoma client is not running") checkClientRunning | ||
|
||
stopClient :: (Members '[Files, EmbedIO] r) => ClientConfig -> Sem r () | ||
stopClient = terminateProcessPid . (^. clientConfigPid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Commands.Dev.Anoma.PrintConfig where | ||
|
||
import Commands.Base | ||
import Commands.Dev.Anoma.Client | ||
import Commands.Dev.Anoma.PrintConfig.Options | ||
import Data.Yaml qualified as Yaml | ||
|
||
runCommand :: (Members AppEffects r) => PrintConfigOptions -> Sem r () | ||
runCommand _ = runAppError @SimpleError $ do | ||
cfg <- (^. clientConfigHost) <$> getClientConfig | ||
renderStdOutRaw (Yaml.encode cfg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Commands.Dev.Anoma.PrintConfig.Options where | ||
|
||
import CommonOptions | ||
|
||
data PrintConfigOptions = PrintConfigOptions | ||
deriving stock (Data) | ||
|
||
parsePrintConfigOptions :: Parser PrintConfigOptions | ||
parsePrintConfigOptions = pure PrintConfigOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters