Skip to content

A peer-to-peer stack for code collaboration

'rad machines create' uses daemon

Thomas Scholtesede28ae4b3f8
diff --git a/exe/Machines.hs b/exe/Machines.hs
index 7abfaef..863bea4 100644
--- a/exe/Machines.hs
+++ b/exe/Machines.hs
@@ -5,10 +5,10 @@ module Machines
import Protolude hiding (option)
-import qualified Data.UUID as UUID
-import qualified Data.UUID.V4 as UUID
+import Control.Exception.Safe
+import qualified Network.HTTP.Client as HttpClient
import Options.Applicative
-import Radicle.Internal.MachineBackend.Ipfs
+import qualified Radicle.Daemon.Client as Client
data Command = CommandCreate
deriving (Show, Eq)
@@ -25,11 +25,10 @@ programParserInfo =
runCommand :: Command -> IO ()
runCommand CommandCreate = do
- label <- UUID.toText <$> UUID.nextRandom
- result <- ipfsMachineCreate label
- case result of
- Left err -> die (toS err)
- Right machineId -> putStrLn machineId
+ httpManager <- HttpClient.newManager HttpClient.defaultManagerSettings
+ runExceptT (Client.newMachine httpManager) >>= \case
+ Left err -> throw err
+ Right (Client.MachineId machineId) -> putStrLn machineId
main :: IO ()
main = do
diff --git a/package.yaml b/package.yaml
index c1f5e28..30daf7e 100644
--- a/package.yaml
+++ b/package.yaml
@@ -216,8 +216,9 @@ executables:
other-modules: []
dependencies:
- radicle
- - uuid
+ - http-client
- optparse-applicative
+ - safe-exceptions
ghc-options: -main-is Machines
default-extensions: