repl

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package repl implements the interactive REPL loop for the netconf CLI tool.

Index

Constants

This section is empty.

Variables

View Source
var Completer = readline.NewPrefixCompleter(
	readline.PcItem("connect",
		readline.PcItem("--host"),
		readline.PcItem("--port"),
		readline.PcItem("--user"),
		readline.PcItem("--password"),
		readline.PcItem("--key"),
		readline.PcItem("--known-hosts"),
		readline.PcItem("--insecure"),
	),
	readline.PcItem("disconnect"),
	readline.PcItem("get",
		readline.PcItem("--filter"),
		readline.PcItem("--subtree"),
		readline.PcItem("--raw"),
	),
	readline.PcItem("get-config",
		readline.PcItem("--source", datastoreItems...),
		readline.PcItem("--filter"),
		readline.PcItem("--subtree"),
		readline.PcItem("--raw"),
	),
	readline.PcItem("edit-config",
		readline.PcItem("--target", datastoreItems...),
		readline.PcItem("--operation",
			readline.PcItem("merge"),
			readline.PcItem("replace"),
			readline.PcItem("none"),
		),
		readline.PcItem("--config"),
	),
	readline.PcItem("copy-config",
		readline.PcItem("--source", datastoreItems...),
		readline.PcItem("--target", datastoreItems...),
	),
	readline.PcItem("delete-config",
		readline.PcItem("--target", datastoreItems...),
	),
	readline.PcItem("lock",
		readline.PcItem("--target", datastoreItems...),
	),
	readline.PcItem("unlock",
		readline.PcItem("--target", datastoreItems...),
	),
	readline.PcItem("commit",
		readline.PcItem("--confirmed"),
		readline.PcItem("--timeout"),
	),
	readline.PcItem("discard"),
	readline.PcItem("validate",
		readline.PcItem("--source", datastoreItems...),
	),
	readline.PcItem("kill-session",
		readline.PcItem("--id"),
	),
	readline.PcItem("capabilities"),
	readline.PcItem("help"),
	readline.PcItem("version"),
	readline.PcItem("exit"),
	readline.PcItem("quit"),
)

Completer is the full flag-aware tab-completion tree for the REPL. It is exported so tests can inspect it.

Functions

func PrintXML

func PrintXML(w io.Writer, body []byte, raw bool)

PrintXML writes XML body to w, indenting it for readability unless raw is true.

When raw is true, the bytes are written verbatim (useful for piping output to other tools or when the caller needs exact bytes).

When raw is false, prettyXML is called to indent the output. If the input is empty, nothing is written.

func Run

func Run(version string) error

Run starts the interactive REPL. It returns only on fatal initialisation errors; normal exit (exit/quit/Ctrl+D) returns nil.

Types

type Session

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

Session holds live NETCONF connection state for the REPL. It is safe to call any method on a zero-value Session.

func (*Session) Client

func (s *Session) Client() *client.Client

Client returns the underlying *client.Client, or nil when not connected.

func (*Session) Close

func (s *Session) Close() error

Close sends a NETCONF close-session RPC and releases the transport. Safe to call on an unconnected Session (no-op). Always clears the session state even if the RPC fails.

func (*Session) Connected

func (s *Session) Connected() bool

Connected reports whether a NETCONF session is currently active.

func (*Session) Host

func (s *Session) Host() string

Host returns the remote host:port string used in the prompt. Returns an empty string when not connected.

func (*Session) IsLocked

func (s *Session) IsLocked(ds string) bool

IsLocked reports whether the named datastore is currently locked by this session.

func (*Session) SetLocked

func (s *Session) SetLocked(ds string, locked bool)

SetLocked records or clears a lock on a named datastore. locked=true marks ds as locked; locked=false clears it.

Jump to

Keyboard shortcuts

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