Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version command to cardano-cli #630

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cardano-config/src/Cardano/Config/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ instance FromJSON ViewMode where
<> "Encountered: " <> (T.pack $ show invalid)

-- | Detailed tracing options. Each option enables a tracer
-- which verbosity to the log output.
-- which logs to the log output.
data TraceOptions = TraceOptions
{ traceVerbosity :: !TracingVerbosity
, traceBlockFetchClient :: !Bool
Expand Down
7 changes: 1 addition & 6 deletions cardano-node/cardano-node.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ library
, base >=4.12 && <5
, bytestring
, deepseq
, strict-concurrency
, canonical-json
, cardano-binary
, cardano-config
Expand All @@ -81,7 +80,6 @@ library
, contra-tracer
, cborg >= 0.2.2 && < 0.3
, containers
, cryptonite
, directory
, filepath
, formatting
Expand All @@ -101,23 +99,20 @@ library
, ouroboros-consensus-byron
, ouroboros-consensus-cardano
, ouroboros-network
, safe-exceptions
, serialise
, stm
, strict-concurrency
, string-conv
, template-haskell
, text
, time
, tracer-transformers
, transformers
, transformers-except
, tracer-transformers
, typed-protocols
, ouroboros-network-framework
, unordered-containers
, utf8-string
, vector
, yaml

default-language: Haskell2010
default-extensions: NoImplicitPrelude
Expand Down
4 changes: 4 additions & 0 deletions cardano-node/src/Cardano/CLI/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ parseMiscellaneous = subparser $ mconcat
$ ValidateCBOR
<$> parseCBORObject
<*> parseFilePath "filepath" "Filepath of CBOR file."
, command'
"version"
"Show cardano-cli version"
$ pure DisplayVersion
, command'
"pretty-print-cbor"
"Pretty print a CBOR file."
Expand Down
17 changes: 15 additions & 2 deletions cardano-node/src/Cardano/CLI/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module Cardano.CLI.Run (
) where

import Cardano.Prelude hiding (option, trace)

import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra (hoistEither, firstExceptT, left)
import qualified Data.ByteString.Lazy as LB
Expand All @@ -45,6 +44,7 @@ import Data.Version (showVersion)
import qualified Formatting as F
import Paths_cardano_node (version)
import System.Directory (doesPathExist)
import System.Info (arch, compilerName, compilerVersion, os)

import qualified Cardano.Chain.Common as Common
import qualified Cardano.Chain.Delegation as Delegation
Expand Down Expand Up @@ -174,7 +174,7 @@ data ClientCommand
(NonEmpty UTxO.TxOut)
-- ^ Genesis UTxO output Address.

--- Tx Generator Command ----------
--- Tx Generator Command ---

| GenerateTxs
FilePath
Expand All @@ -193,17 +193,30 @@ data ClientCommand
(Maybe TxAdditionalSize)
(Maybe ExplorerAPIEnpoint)
[SigningKeyFile]

--- Misc Commands ---

| DisplayVersion

| ValidateCBOR
CBORObject
-- ^ Type of the CBOR object
FilePath

| PrettyPrintCBOR
FilePath
deriving Show


runCommand :: ClientCommand -> ExceptT CliError IO ()
runCommand DisplayVersion = do
liftIO . putTextLn
. toS
$ concat [ "cardano-cli " <> showVersion version
, " - " <> os <> "-" <> arch
, " - " <> compilerName <> "-" <> showVersion compilerVersion
]

runCommand (Genesis outDir params ptcl) = do
gen <- mkGenesis params
dumpGenesis ptcl outDir `uncurry` gen
Expand Down