{"modulePath":"github.com/chainopen/matrixchaincode","version":"v0.0.0-20190924071332-ddf2b42e220f","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package console\n\n## Constants\n\n```go\nconst DefaultPrompt = \"\u003e \"\n```\nDefaultPrompt is the default prompt line prefix to use for user input querying.\n\n```go\nconst HistoryFile = \"history\"\n```\nHistoryFile is the file within the data directory to store input scrollback.\n\n## Variables\n\n```go\nvar Stdin = newTerminalPrompter()\n```\nStdin 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.\n\n## Types\n\n```go\ntype Config struct {\n\tDataDir  string       // Data directory to store the console history at\n\tDocRoot  string       // Filesystem path from where to load JavaScript files from\n\tClient   *rpc.Client  // RPC client to execute Matrix requests through\n\tPrompt   string       // Input prompt prefix string (defaults to DefaultPrompt)\n\tPrompter UserPrompter // Input prompter to allow interactive user feedback (defaults to TerminalPrompter)\n\tPrinter  io.Writer    // Output writer to serialize any display strings to (defaults to os.Stdout)\n\tPreload  []string     // Absolute paths to JavaScript files to preload\n}\n```\nConfig is the collection of configurations to fine tune the behavior of the JavaScript console.\n\n```go\ntype Console struct {\n\t// contains filtered or unexported fields\n}\n```\nConsole is a JavaScript interpreted runtime environment. It is a fully fleged JavaScript console attached to a running node via an external or in-process RPC client.\n\n```go\nfunc New(config Config) (*Console, error)\n```\n\n```go\nfunc (c *Console) AutoCompleteInput(line string, pos int) (string, []string, string)\n```\nAutoCompleteInput is a pre-assembled word completer to be used by the user input prompter to provide hints to the user about the methods available.\n\n```go\nfunc (c *Console) Evaluate(statement string) error\n```\nEvaluate executes code and pretty prints the result to the specified output stream.\n\n```go\nfunc (c *Console) Execute(path string) error\n```\nExecute runs the JavaScript file specified as the argument.\n\n```go\nfunc (c *Console) Interactive()\n```\nInteractive starts an interactive user session, where input is propted from the configured user prompter.\n\n```go\nfunc (c *Console) Stop(graceful bool) error\n```\nStop cleans up the console and terminates the runtime environment.\n\n```go\nfunc (c *Console) Welcome()\n```\nWelcome show summary of current Gman instance and some metadata about the console's available modules.\n\n```go\ntype UserPrompter interface {\n\t// PromptInput displays the given prompt to the user and requests some textual\n\t// data to be entered, returning the input of the user.\n\tPromptInput(prompt string) (string, error)\n\n\t// PromptPassword displays the given prompt to the user and requests some textual\n\t// data to be entered, but one which must not be echoed out into the terminal.\n\t// The method returns the input provided by the user.\n\tPromptPassword(prompt string) (string, error)\n\n\t// PromptConfirm displays the given prompt to the user and requests a boolean\n\t// choice to be made, returning that choice.\n\tPromptConfirm(prompt string) (bool, error)\n\n\t// SetHistory sets the the input scrollback history that the prompter will allow\n\t// the user to scroll back to.\n\tSetHistory(history []string)\n\n\t// AppendHistory appends an entry to the scrollback history. It should be called\n\t// if and only if the prompt to append was a valid command.\n\tAppendHistory(command string)\n\n\t// ClearHistory clears the entire history\n\tClearHistory()\n\n\t// SetWordCompleter sets the completion function that the prompter will call to\n\t// fetch completion candidates when the user presses tab.\n\tSetWordCompleter(completer WordCompleter)\n}\n```\nUserPrompter defines the methods needed by the console to promt the user for various types of inputs.\n\n```go\ntype WordCompleter func(line string, pos int) (string, []string, string)\n```\nWordCompleter 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!!!\".\n\n","path":"github.com/chainopen/matrixchaincode/console","name":"console","synopsis":"","isRedistributable":true}
