Documentation
¶
Index ¶
- Constants
- Variables
- func Banner(msg string)
- func BannerTitle(msg string)
- func BlankLine()
- func CheckIfExists(dir string) bool
- func CheckIsDir(file string) (bool, error)
- func CheckPeersAddress(peerfile string, babbleListen string) (bool, error)
- func ClearScreen()
- func ContinuePrompt()
- func CopyFileContents(src, dst string) (err error)
- func CreateNewConfig(configDir string) error
- func DefaultHomeDir(tomlDir string) (string, error)
- func FaceOut(NewColour color.Attribute)
- func GetMyIP() string
- func GetNodeSafeLabel(moniker string) string
- func IsValidAddress(v string) bool
- func LoadToml(tomlFile string) (*toml.Tree, error)
- func LoadTomlConfig(configDir string) (*toml.Tree, error)
- func Message(a ...interface{}) (n int, err error)
- func MessageWithType(msgType int, a ...interface{}) (n int, err error)
- func PublicKeyHexToAddressHex(publicKey string) (string, error)
- func RequestBool(promptText string, defaultValue bool) bool
- func RequestFile(promptText string, defaultValue string) string
- func RequestPassword(promptText string, defaultValue string) string
- func RequestSelect(promptText string, answerSet []string, defaultValue string) string
- func RequestString(promptText string, defaultValue string) string
- func SafeRenameDir(origDir string) error
- func SaveToml(tree *toml.Tree, tomlFile string) error
- func SaveTomlConfig(configDir string, tree *toml.Tree) error
- func SetParamsWithParams(configDir string) error
- func ShowConfigFile(filename string) error
- func TransformCliTomlToD(tree *toml.Tree, monetConfigDir string) error
- func WriteToFile(filename string, data string) error
- type KeyValue
Constants ¶
const ( MonetdTomlDirDot = ".monet" MonetcliTomlDirDot = ".monetcli" MonetdTomlDirCaps = "MONET" MonetcliTomlDirCaps = "MONETCLI" BabbleDir = "babble" EthDir = "eth" PwdFile = "pwd.txt" PublishDir = "publish" DefaultKeyfile = "keyfile.json" EvmlcTomlDirCaps = "EVMLC" EvmlcTomlDirDot = ".evmlc" TomlSuffix = ".toml" MonetdTomlName = "monetd" MonetcliTomlName = "network" EvmlcTomlName = "config" PeersJSON = "peers.json" PeersGenesisJSON = "peers.genesis.json" GenesisJSON = "genesis.json" PeersJSONTarget = "babble/peers.json" PeersGenesisJSONTarget = "babble/peers.genesis.json" GenesisJSONTarget = "eth/genesis.json" // Commented out value was used when monetd repo was private // DefaultSolidityContract = "https://raw.githubusercontent.com/mosaicnetworks/evm-lite/poa/e2e/smart-contracts/monet.sol" DefaultSolidityContract = "https://raw.githubusercontent.com/mosaicnetworks/monetd/master/smart-contract/genesis.sol" TemplateContract = "template.sol" GenesisContract = "contract0.sol" GenesisABI = "contract0.abi" DefaultAccountBalance = "1234000000000000000000" DefaultContractAddress = "abbaabbaabbaabbaabbaabbaabbaabbaabbaabba" )
Constants for files names and default values used in building configurations
const ( ColourInfo = color.FgGreen ColourWarning = color.FgHiMagenta ColourError = color.FgHiRed ColourPrompt = color.FgHiYellow ColourOther = color.FgYellow ColourOutput = color.FgHiCyan ColourDebug = color.FgCyan )
Colour constants used in the functions in src/common/logs.go
const ( MsgInformation = 0 MsgWarning = 1 MsgError = 2 MsgPrompt = 3 MsgDebug = 4 MsgOther = 5 )
Log level constants
const ( WizardExit = "Exit" WizardTextCreateNewConfiguration = "Create New Configuration" WizardExitWithoutSavingChanges = "Exit Without Saving Changes" WizardEditExistingConfiguration = "Edit Existing Configuration" WizardChangeConfigDir = "Change Configuration Directory" WizardRenameCurrentDirectoryandCreateNewConfiguration = "Rename Current Directory and Create New Configuration" WizardAddKeyPair = "Add Key Pair" WizardCheckConfiguration = "Check Configuration" WizardCompile = "Compile POA Contract" WizardGenerate = "Generate Key Pair" WizardParams = "Edit Params" WizardShow = "Show Configuration" WizardView = "View" WizardEdit = "Edit" WizardDelete = "Delete" WizardSaveChanges = "Save Changes" WizardCancelChanges = "Cancel Changes" WizardEditAgain = "Edit Again" WizardPeers = "Peers" WizardVersion = "Version Info" )
Constants for the labels used in Wizard select options. Constants are much safer than string literals for parsing the results of select commands.
Variables ¶
var ( //MonetdTomlDir contains the directory name for the monetd config //It varies by OS MonetdTomlDir string //MonetcliTomlDir contains the directory name for the monetd config //It varies by OS MonetcliTomlDir string //EvmlcTomlDir contains the directory name for the monetd config //It varies by OS EvmlcTomlDir string )
var ( //VerboseLogging controls where Message produces any output VerboseLogging = true //HideBanners Suppresses the figlet banner HideBanners = false )
Functions ¶
func BannerTitle ¶
func BannerTitle(msg string)
BannerTitle wraps ClearScreen, Banner and BlankLine to show a title on a cleared page with a blankline underneath
func CheckIfExists ¶
CheckIfExists checks if a file / directory exists
func CheckIsDir ¶
CheckIsDir checks if file is a directory
func CheckPeersAddress ¶
CheckPeersAddress verifies that a given peer is in the peers file In particular that the configured babble listener is in exactly the same form within the peers file
func ClearScreen ¶
func ClearScreen()
ClearScreen clears the CLI screen. Implementation is OS-specific
func CopyFileContents ¶
CopyFileContents writes the contents to src to a new file dst. This operation is silently destructive
func CreateNewConfig ¶
CreateNewConfig creates a new configuration with a single parameter. The defaults will take care of all else.
func DefaultHomeDir ¶
DefaultHomeDir returns a default location for a configuration file.
func GetNodeSafeLabel ¶
GetNodeSafeLabel converts a free format string into a node label friendly format Anything other than an alphanumeric is converted to _
func IsValidAddress ¶
IsValidAddress checks if is a valid ethereum style address
func LoadTomlConfig ¶
LoadTomlConfig is a wrapper to LoadToml, that explicitly loads a monetcli config
func Message ¶
Message is a simple wrapper for stdout logging. Setting VerboseLayout to false disables its output
func MessageWithType ¶
MessageWithType is a central point for cli logging messages It colour codes the output, suppressing Debug messages if --verbose option not enabled
func PublicKeyHexToAddressHex ¶
PublicKeyHexToAddressHex takes a Hex string public key and returns a hex string Ethereum style address
func RequestBool ¶
RequestBool prompts the user for a boolean answer and parses the string to return a bool type
func RequestFile ¶
RequestFile prompts the user for a file name.
func RequestPassword ¶
RequestPassword prompts the user for input using a mask to hide their answer
func RequestSelect ¶
RequestSelect is a wrapper to a promptui selecting one from an option
func RequestString ¶
RequestString prompts the user for a string
func SafeRenameDir ¶
SafeRenameDir renames a folder to folder.~n~ where n is the lowest value where the folder does not already exist. n is capped at 100 - which would require the user to manually tidy the parent folder.
func SaveTomlConfig ¶
SaveTomlConfig is a wrapper to SaveToml, that explicitly saves a monetcli config
func SetParamsWithParams ¶
SetParamsWithParams allows the interactive editing of parameters in the cli config file
func ShowConfigFile ¶
ShowConfigFile echoes the given file to screen
func TransformCliTomlToD ¶
TransformCliTomlToD process monetcli config to become a monetd config - largely by removing unused keys which are used for peers and genesis files.
func WriteToFile ¶
WriteToFile writes a string variable to a file. It overwrites any pre-existing data silently.
Types ¶
type KeyValue ¶
type KeyValue struct {
Key string
Value interface{}
Override bool
Prompt string
Answers []string
DataType string
}
KeyValue is a struct for holding toml keys, default values and whether the default overrides the monetcli supplied value
func GetMonetDefaultConfigKeys ¶
GetMonetDefaultConfigKeys defines the default config values