Skip to content

Commit

Permalink
Modules beta
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaste committed Jul 4, 2024
1 parent af58c37 commit 04ab7a7
Show file tree
Hide file tree
Showing 16 changed files with 2,423 additions and 2,172 deletions.
69 changes: 32 additions & 37 deletions bench/cardano-profile/app/cardano-profile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy.Char8 as BSL8
import qualified Options.Applicative as OA

import qualified Cardano.Benchmarking.Profile as Profile
import qualified Cardano.Benchmarking.Profile.Map as Map
import qualified Cardano.Benchmarking.Profile as Profiles
import qualified Cardano.Benchmarking.Profile.Types as Types

--------------------------------------------------------------------------------

Expand All @@ -29,18 +29,18 @@ main = do
)
case cli of
-- Print all profile names.
Names -> BSL8.putStrLn $ Aeson.encode $ Map.names
Names -> BSL8.putStrLn $ Aeson.encode Profiles.names
-- Print a map with all profiles, with an optional overlay.
All -> do
obj <- lookupOverlay
BSL8.putStrLn $ Aeson.encode $ Map.profiles obj
BSL8.putStrLn $ Aeson.encode $ Profiles.profiles obj
-- Print a single profiles, with an optional overlay.
(Make profileName) -> do
obj <- lookupOverlay
case Map.byName profileName obj of
case Profiles.byName profileName obj of
Nothing -> error $ "No profile named \"" ++ profileName ++ "\""
(Just profile) ->
let aeson = Aeson.encode $ profile
let aeson = Aeson.encode profile
in BSL8.putStrLn aeson
(ToJson filePath) -> print filePath
-- str <- readFile filePath
Expand All @@ -51,7 +51,7 @@ main = do
eitherProfile <- Aeson.eitherDecodeFileStrict filePath
case eitherProfile of
(Left errorMsg) -> fail errorMsg
(Right profile) -> putStrLn $ show (profile :: Profile.Profile)
(Right profile) -> print (profile :: Types.Profile)

lookupOverlay :: IO Aeson.Object
lookupOverlay = do
Expand All @@ -66,40 +66,35 @@ lookupOverlay = do

cliParser :: OA.Parser Cli
cliParser = OA.hsubparser $
(OA.command "names"
(OA.info
(pure Names)
(OA.fullDesc <> OA.header "names" <> OA.progDesc "All profiles names")
)
)
OA.command "names"
(OA.info
(pure Names)
(OA.fullDesc <> OA.header "names" <> OA.progDesc "All profiles names")
)
<>
(OA.command "all"
(OA.info
(pure All)
(OA.fullDesc <> OA.header "all" <> OA.progDesc "All profiles")
)
)
OA.command "all"
(OA.info
(pure All)
(OA.fullDesc <> OA.header "all" <> OA.progDesc "All profiles")
)
<>
(OA.command "make"
(OA.info
(Make <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
(OA.fullDesc <> OA.header "make" <> OA.progDesc "Create profile")
)
)
OA.command "make"
(OA.info
(Make <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
(OA.fullDesc <> OA.header "make" <> OA.progDesc "Create profile")
)
<>
(OA.command "to-json"
(OA.info
(ToJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "to-json" <> OA.progDesc "Data type to JSON")
)
)
OA.command "to-json"
(OA.info
(ToJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "to-json" <> OA.progDesc "Data type to JSON")
)
<>
(OA.command "from-json"
(OA.info
(FromJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "from-json" <> OA.progDesc "JSON to data type")
)
)
OA.command "from-json"
(OA.info
(FromJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "from-json" <> OA.progDesc "JSON to data type")
)

--------------------------------------------------------------------------------

Expand Down
11 changes: 10 additions & 1 deletion bench/cardano-profile/cardano-profile.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ library
other-modules: Paths_cardano_profile
autogen-modules: Paths_cardano_profile
exposed-modules: Cardano.Benchmarking.Profile
, Cardano.Benchmarking.Profile.Map
, Cardano.Benchmarking.Profile.Builtin.Cloud
, Cardano.Benchmarking.Profile.Builtin.Empty
, Cardano.Benchmarking.Profile.Builtin.ForgeStress
, Cardano.Benchmarking.Profile.Builtin.Scaling
, Cardano.Benchmarking.Profile.Builtin.Scenario.Chainsync
, Cardano.Benchmarking.Profile.Builtin.Scenario.Latency
, Cardano.Benchmarking.Profile.Builtin.Scenario.Idle
, Cardano.Benchmarking.Profile.Builtin.Scenario.TracerOnly
, Cardano.Benchmarking.Profile.Primitives
, Cardano.Benchmarking.Profile.Vocabulary
, Cardano.Benchmarking.Profile.Types
build-depends: base >=4.12 && <5
, time
Expand Down
Loading

0 comments on commit 04ab7a7

Please sign in to comment.