commands

package
v0.0.0-...-5a930d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrompt = "> "

DefaultPrompt is the default prompt line prefix to use for user input querying.

View Source
const HistoryFile = "history"

HistoryFile is the file within the data directory to store input scrollback.

View Source
const (
	Name = "wallet-cli:"
)

Variables

View Source
var ConsoleCmd = &cobra.Command{
	Use:   "console",
	Short: "interactive mode",
	Example: `
		Enter console mode
		`,
	Args: cobra.MaximumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		b := checkWalletIeExist(config.Cfg)
		if b == false {
			fmt.Println("Please create a wallet first,[qitmeer-wallet qc create ]")
			return
		}
		needMn := ""
		if len(args) >= 1 {
			needMn = args[0]
		}
		startConsole(needMn)
	},
}
View Source
var QcCmd = &cobra.Command{
	Use:   "qc",
	Short: "qitmeer wallet command",
	Long:  `qitmeer wallet command`,
}
View Source
var QxCmd = &cobra.Command{
	Use:   "qx",
	Short: "qx util",
	Long:  `qitmeer wallet qx util`,
}
View Source
var RootCmd = &cobra.Command{
	Use: "qitmeer-wallet",
}
View Source
var Stdin = newTerminalPrompter()

Stdin holds the stdin line reader (also using stdout for printing prompts). Only this reader may be used for input because it keeps an internal buffer.

View Source
var WebCmd = &cobra.Command{
	Use:   "web",
	Short: "web administration UI",
	Example: `
		Enter web mode
		`,
	Args: cobra.NoArgs,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("web model")
		qitmeerMain(userConf)
	},
}

Functions

func AddConsoleCommand

func AddConsoleCommand()

func AddQcCommand

func AddQcCommand()

func AddQxCommand

func AddQxCommand()

func AddWebCommand

func AddWebCommand()

func ClearTxData

func ClearTxData() error

func CreatWallet

func CreatWallet(needMnemonic string)

func GetTxSpendInfo

func GetTxSpendInfo(txId string) ([]*wtxmgr.AddrTxOutput, error)

func Glogger

func Glogger() *log.GlogHandler

func InitLogRotator

func InitLogRotator(logFile string)

initLogRotator initializes the logging rotater to write logs to logFile and create roll files in the same directory. It must be called before the package-global log rotater variables are used.

func LogWrite

func LogWrite() *logWriter

func OpenWallet

func OpenWallet() error

func SetSyncedToNum

func SetSyncedToNum(order int64) error

func UnLock

func UnLock(password string) error

Types

type Config

type Config struct {
	DataDir  string       // Data directory to store the console history at
	DocRoot  string       // Filesystem path from where to load JavaScript files from
	Prompt   string       // Input prompt prefix string (defaults to DefaultPrompt)
	Prompter UserPrompter // Input prompter to allow interactive user feedback (defaults to TerminalPrompter)
	Printer  io.Writer    // Output writer to serialize any display strings to (defaults to os.Stdout)
	Preload  []string     // Absolute paths to JavaScript files to preload
}

Config is the collection of configurations to fine tune the behavior of the JavaScript console.

type Console

type Console struct {
	// contains filtered or unexported fields
}

Console is a JavaScript interpreted runtime environment. It is a fully fledged JavaScript console attached to a running node via an external or in-process RPC client.

func New

func New(config Config) (*Console, error)

New initializes a JavaScript interpreted runtime environment and sets defaults with the config struct.

func (*Console) AutoCompleteInput

func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, string)

AutoCompleteInput is a pre-assembled word completer to be used by the user input prompter to provide hints to the user about the methods available.

func (*Console) Interactive

func (c *Console) Interactive()

Interactive starts an interactive user session, where input is propted from the configured user prompter.

type JsonCmdHelper

type JsonCmdHelper struct {
	JsonCmd interface{}
	Run     func(interface{}, *wallet.Wallet) (interface{}, error)
}

func (*JsonCmdHelper) Call

func (h *JsonCmdHelper) Call() (interface{}, error)

type UserPrompter

type UserPrompter interface {
	// PromptInput displays the given prompt to the user and requests some textual
	// data to be entered, returning the input of the user.
	PromptInput(prompt string) (string, error)

	// PromptPassword displays the given prompt to the user and requests some textual
	// data to be entered, but one which must not be echoed out into the terminal.
	// The method returns the input provided by the user.
	PromptPassword(prompt string) (string, error)

	// PromptConfirm displays the given prompt to the user and requests a boolean
	// choice to be made, returning that choice.
	PromptConfirm(prompt string) (bool, error)

	// SetHistory sets the input scrollback history that the prompter will allow
	// the user to scroll back to.
	SetHistory(history []string)

	// AppendHistory appends an entry to the scrollback history. It should be called
	// if and only if the prompt to append was a valid command.
	AppendHistory(command string)

	// ClearHistory clears the entire history
	ClearHistory()

	// SetWordCompleter sets the completion function that the prompter will call to
	// fetch completion candidates when the user presses tab.
	SetWordCompleter(completer WordCompleter)
}

UserPrompter defines the methods needed by the console to prompt the user for various types of inputs.

type WordCompleter

type WordCompleter func(line string, pos int) (string, []string, string)

WordCompleter takes the currently edited line with the cursor position and returns the completion candidates for the partial word to be completed. If the line is "Hello, wo!!!" and the cursor is before the first '!', ("Hello, wo!!!", 9) is passed to the completer which may returns ("Hello, ", {"world", "Word"}, "!!!") to have "Hello, world!!!".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL