Skip to content

Commit

Permalink
Remove optparse-applicative-fork dependency, and functions depending …
Browse files Browse the repository at this point in the history
…on it
  • Loading branch information
smelc committed Sep 12, 2024
1 parent bf84187 commit 93173da
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 28 deletions.
1 change: 0 additions & 1 deletion cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ library internal
microlens-aeson,
mtl,
network,
optparse-applicative-fork,
ouroboros-consensus ^>=0.20,
ouroboros-consensus-cardano ^>=0.19,
ouroboros-consensus-diffusion ^>=0.17,
Expand Down
23 changes: 0 additions & 23 deletions cardano-api/internal/Cardano/Api/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@ module Cardano.Api.Utils
, failEitherWith
, noInlineMaybeToStrictMaybe
, note
, parseFilePath
, readFileBlocking
, runParsecParser
, textShow
, modifyWith

-- ** CLI option parsing
, bounded
, unsafeBoundedRational
)
where

import Cardano.Ledger.BaseTypes
import Cardano.Ledger.Shelley ()
import Control.Exception (bracket)
import Control.Monad (when)
import qualified Data.Aeson.Types as Aeson
import qualified Data.ByteString as BS
import qualified Data.ByteString.Builder as Builder
Expand All @@ -45,14 +42,10 @@ import qualified Data.Text as Text
import Data.Typeable
import GHC.IO.Handle.FD (openFileBlocking)
import GHC.Stack
import Options.Applicative (ReadM)
import qualified Options.Applicative as Opt
import Options.Applicative.Builder (eitherReader)
import System.IO (IOMode (ReadMode), hClose)
import qualified Text.Parsec as Parsec
import qualified Text.Parsec.String as Parsec
import qualified Text.ParserCombinators.Parsec.Error as Parsec
import qualified Text.Read as Read

(?!) :: Maybe a -> e -> Either e a
Nothing ?! e = Left e
Expand Down Expand Up @@ -94,15 +87,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")
)

readFileBlocking :: FilePath -> IO BS.ByteString
readFileBlocking path =
bracket
Expand All @@ -123,13 +107,6 @@ readFileBlocking path =
textShow :: Show a => a -> Text
textShow = Text.pack . show

bounded :: forall a. (Bounded a, Integral a, Show a) => String -> ReadM a
bounded t = eitherReader $ \s -> do
i <- Read.readEither @Integer s
when (i < fromIntegral (minBound @a)) $ Left $ t <> " must not be less than " <> show (minBound @a)
when (i > fromIntegral (maxBound @a)) $ Left $ t <> " must not greater than " <> show (maxBound @a)
pure (fromIntegral i)

-- | Aids type inference. Use this function to ensure the value is a function
-- that modifies a value.
modifyWith
Expand Down
4 changes: 0 additions & 4 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ module Cardano.Api
, chainPointToSlotNo
, chainPointToHeaderHash
, makeChainTip
, parseFilePath
, writeSecrets

-- * Convenience functions
Expand All @@ -949,9 +948,6 @@ module Cardano.Api
, notScriptLockedTxIns
, textShow

-- ** CLI option parsing
, bounded

-- ** Query expressions
, queryAccountState
, queryChainBlockNo
Expand Down

0 comments on commit 93173da

Please sign in to comment.