A peer-to-peer stack for code collaboration
Replace script to create Rad machines with binary
Thomas Scholtesf528a6e19ef2
diff --git a/bin/rad-ipfs-machine-create b/bin/rad-ipfs-machine-createdeleted file mode 100755index 166ad67..0000000--- a/bin/rad-ipfs-machine-create+++ /dev/null@@ -1,17 +0,0 @@-#!/usr/bin/env bash-#-# rad-ipfs-machine-create [local-name]-#-# Creates a new Radicle State Machine on IPFS and prints the machine-# ID.-#-# If `local-name` is provided it uses this value to name the machines-# IPNS key on the local IPFS daemon. By default a UUID is used.--set -euo pipefail--ipns_name=${1:-$(uuidgen)}-empty_machine="zdpuAyyGtvC37aeZid2zh7LAGKCbFTn9MzdqoPpbNQm3BCwWT"-ipns_id=$(bin/rad-ipfs key gen "$ipns_name" --type ed25519)-bin/rad-ipfs name publish --key "$ipns_id" "$empty_machine" >/dev/null-echo "$ipns_id"diff --git a/exe/Machines.hs b/exe/Machines.hsnew file mode 100644index 0000000..7abfaef--- /dev/null+++ b/exe/Machines.hs@@ -0,0 +1,37 @@+-- | CLI for managing Radicle machines on IPFS+module Machines+ ( main+ ) where++import Protolude hiding (option)++import qualified Data.UUID as UUID+import qualified Data.UUID.V4 as UUID+import Options.Applicative+import Radicle.Internal.MachineBackend.Ipfs++data Command = CommandCreate+ deriving (Show, Eq)++commandParser :: Parser Command+commandParser = subparser $+ command "create"+ (info (pure CommandCreate <**> helper)+ (progDesc "Create a Radicle machine and output its ID" ))++programParserInfo :: ParserInfo Command+programParserInfo =+ info (commandParser <**> helper) (progDesc "Manage Radicle machines on IPFS")++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++main :: IO ()+main = do+ cmd <- execParser programParserInfo+ runCommand cmddiff --git a/package.yaml b/package.yamlindex 7572c16..170f518 100644--- a/package.yaml+++ b/package.yaml@@ -12,7 +12,12 @@ dependencies:- base >=4 && <5- protoludeghc-options:- -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+ - -Wall+ - -Wcompat+ - -Wincomplete-record-updates+ - -Wincomplete-uni-patterns+ - -Wredundant-constraints+ - -threadeddata-files:- rad/**/*.rad@@ -55,7 +60,6 @@ tests:main: Main.hssource-dirs:- test/spec- ghc-options: -threadeddependencies:- radicle- containers@@ -80,7 +84,6 @@ tests:main: Main.hssource-dirs:- test/docs- ghc-options: -threadeddependencies:- doctest- Glob@@ -99,7 +102,7 @@ executables:when:- condition: impl(ghcjs)buildable: false- ghc-options: -main-is RadicleExe -O3 -threaded+ ghc-options: -main-is RadicleExeradicle-server:main: Server.hs@@ -121,7 +124,7 @@ executables:- warp- wai-extra- wai-cors- ghc-options: -main-is Server -O3 -threaded+ ghc-options: -main-is Serverradicle-client-ghcjs:main: GHCJS.hs@@ -148,7 +151,7 @@ executables:# in ghcjs due to the metadata initializer only supporting objects with up# to 100# fields: https://github.com/ghcjs/ghcjs/issues/498#issuecomment-230725647- ghc-options: -main-is GHCJS -threaded -debug+ ghc-options: -main-is GHCJS -debugradicle-doc:main: Doc.hs@@ -207,6 +210,19 @@ executables:- criterionghc-options: -main-is Benchmarks+ rad-machines:+ main: Machines.hs+ source-dirs: exe/+ other-modules: []+ when:+ - condition: impl(ghcjs)+ buildable: false+ dependencies:+ - radicle+ - uuid+ - optparse-applicative+ ghc-options: -main-is Machines+default-extensions:- AutoDeriveTypeable- ConstraintKindsdiff --git a/src/Radicle/Internal/MachineBackend/Ipfs.hs b/src/Radicle/Internal/MachineBackend/Ipfs.hsindex e7edbf8..d6a3414 100644--- a/src/Radicle/Internal/MachineBackend/Ipfs.hs+++ b/src/Radicle/Internal/MachineBackend/Ipfs.hs@@ -17,6 +17,7 @@--module Radicle.Internal.MachineBackend.Ipfs( ipfsPrimFns+ , ipfsMachineCreate) whereimport Protolude hiding (TypeError, catch, try)