Skip to content

Commit

Permalink
Move parseFilePath to Cardano.Api.Options module
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Mar 27, 2023
1 parent 93b1ec4 commit 0f83e67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 10 additions & 0 deletions cardano-api/src/Cardano/Api/Options.hs
Expand Up @@ -4,6 +4,7 @@ module Cardano.Api.Options
( fileOption
, inFileOption
, outFileOption
, parseFilePath
) where

import Cardano.Api.IO (File (..), In, Out)
Expand All @@ -21,3 +22,12 @@ inFileOption = fileOption

outFileOption :: forall. Mod OptionFields FilePath -> Parser (File Out)
outFileOption = fileOption

parseFilePath :: String -> String -> Opt.Parser FilePath
parseFilePath optname desc =
Opt.strOption
( Opt.long optname
<> Opt.metavar "FILEPATH"
<> Opt.help desc
<> Opt.completer (Opt.bashCompleter "file")
)
11 changes: 0 additions & 11 deletions cardano-api/src/Cardano/Api/Utils.hs
Expand Up @@ -19,7 +19,6 @@ module Cardano.Api.Utils
, failEitherWith
, noInlineMaybeToStrictMaybe
, note
, parseFilePath
, readFileBlocking
, renderEra
, runParsecParser
Expand All @@ -40,7 +39,6 @@ import Data.Maybe.Strict
import Data.Text (Text)
import qualified Data.Text as Text
import GHC.IO.Handle.FD (openFileBlocking)
import qualified Options.Applicative as Opt
import System.FilePath ((</>))
import System.IO (IOMode (ReadMode), hClose)
import qualified Text.Parsec as Parsec
Expand Down Expand Up @@ -94,15 +92,6 @@ note msg = \case
Nothing -> fail msg
Just a -> pure a

parseFilePath :: String -> String -> Opt.Parser FilePath
parseFilePath optname desc =
Opt.strOption
( Opt.long optname
<> Opt.metavar "FILEPATH"
<> Opt.help desc
<> Opt.completer (Opt.bashCompleter "file")
)

writeSecrets :: FilePath -> [Char] -> [Char] -> (a -> BS.ByteString) -> [a] -> IO ()
writeSecrets outDir prefix suffix secretOp xs =
forM_ (zip xs [0::Int ..]) $
Expand Down

0 comments on commit 0f83e67

Please sign in to comment.