Proof-of-concept of brick
TUI
#59
4 changed files with 45 additions and 9 deletions
36
app/Main.hs
36
app/Main.hs
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
import Brick (simpleMain)
|
||||||
import Control.Monad (void)
|
import Control.Monad (void)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
|
@ -12,9 +13,11 @@ import qualified Data.Text as T
|
||||||
import qualified Data.Text.IO as TIO
|
import qualified Data.Text.IO as TIO
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import System.Console.StructuredCLI
|
import System.Console.StructuredCLI
|
||||||
|
import System.Environment (getArgs)
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.IO
|
import System.IO
|
||||||
import Text.Read (readMaybe)
|
import Text.Read (readMaybe)
|
||||||
|
import Zenith.CLI
|
||||||
import Zenith.Types (ZcashAddress(..), ZcashPool(..), ZcashTx(..))
|
import Zenith.Types (ZcashAddress(..), ZcashPool(..), ZcashTx(..))
|
||||||
import Zenith.Utils
|
import Zenith.Utils
|
||||||
import Zenith.Zcashd
|
import Zenith.Zcashd
|
||||||
|
@ -196,14 +199,29 @@ processUri user pwd =
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
config <- load ["zenith.cfg"]
|
config <- load ["zenith.cfg"]
|
||||||
|
args <- getArgs
|
||||||
nodeUser <- require config "nodeUser"
|
nodeUser <- require config "nodeUser"
|
||||||
nodePwd <- require config "nodePwd"
|
nodePwd <- require config "nodePwd"
|
||||||
checkServer nodeUser nodePwd
|
if not (null args)
|
||||||
void $
|
then do
|
||||||
runCLI
|
case head args of
|
||||||
"Zenith"
|
"legacy" -> do
|
||||||
def
|
checkServer nodeUser nodePwd
|
||||||
{ getBanner =
|
void $
|
||||||
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
runCLI
|
||||||
}
|
"Zenith"
|
||||||
(root nodeUser nodePwd)
|
def
|
||||||
|
{ getBanner =
|
||||||
|
" ______ _ _ _ \n |___ / (_) | | | \n / / ___ _ __ _| |_| |__ \n / / / _ \\ '_ \\| | __| '_ \\ \n / /_| __/ | | | | |_| | | |\n /_____\\___|_| |_|_|\\__|_| |_|\n Zcash Full Node CLI v0.4.0"
|
||||||
|
}
|
||||||
|
(root nodeUser nodePwd)
|
||||||
|
"cli" -> simpleMain ui
|
||||||
|
_ -> printUsage
|
||||||
|
else printUsage
|
||||||
|
|
||||||
|
printUsage :: IO ()
|
||||||
|
printUsage = do
|
||||||
|
putStrLn "zenith [command] [parameters]\n"
|
||||||
|
putStrLn "Available commands:"
|
||||||
|
putStrLn "legacy\tLegacy CLI for zcashd"
|
||||||
|
putStrLn "cli\tCLI for zebrad"
|
||||||
|
|
|
@ -43,6 +43,7 @@ library:
|
||||||
- persistent
|
- persistent
|
||||||
- persistent-sqlite
|
- persistent-sqlite
|
||||||
- persistent-template
|
- persistent-template
|
||||||
|
- brick
|
||||||
- zcash-haskell
|
- zcash-haskell
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
|
@ -64,6 +65,7 @@ executables:
|
||||||
- text
|
- text
|
||||||
- time
|
- time
|
||||||
- sort
|
- sort
|
||||||
|
- brick
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
zenith-test:
|
zenith-test:
|
||||||
|
|
13
src/Zenith/CLI.hs
Normal file
13
src/Zenith/CLI.hs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module Zenith.CLI where
|
||||||
|
|
||||||
|
import Brick (Widget, (<+>), joinBorders, simpleMain, str, withBorderStyle)
|
||||||
|
import Brick.Widgets.Border (borderWithLabel, vBorder)
|
||||||
|
import Brick.Widgets.Border.Style (unicode)
|
||||||
|
import Brick.Widgets.Center (center)
|
||||||
|
|
||||||
|
ui :: Widget ()
|
||||||
|
ui =
|
||||||
|
joinBorders $
|
||||||
|
withBorderStyle unicode $
|
||||||
|
borderWithLabel (str "Zenith") $
|
||||||
|
(center (str "Addresses") <+> vBorder <+> center (str "Transactions"))
|
|
@ -25,6 +25,7 @@ source-repository head
|
||||||
|
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
|
Zenith.CLI
|
||||||
Zenith.DB
|
Zenith.DB
|
||||||
Zenith.Types
|
Zenith.Types
|
||||||
Zenith.Utils
|
Zenith.Utils
|
||||||
|
@ -39,6 +40,7 @@ library
|
||||||
, array
|
, array
|
||||||
, base >=4.7 && <5
|
, base >=4.7 && <5
|
||||||
, base64-bytestring
|
, base64-bytestring
|
||||||
|
, brick
|
||||||
, bytestring
|
, bytestring
|
||||||
, http-conduit
|
, http-conduit
|
||||||
, http-types
|
, http-types
|
||||||
|
@ -64,6 +66,7 @@ executable zenith
|
||||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wunused-imports
|
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Wunused-imports
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
|
, brick
|
||||||
, bytestring
|
, bytestring
|
||||||
, configurator
|
, configurator
|
||||||
, data-default
|
, data-default
|
||||||
|
|
Loading…
Reference in a new issue