Documentation ¶
Index ¶
- Constants
- Variables
- func ChangeFmt(f string)
- func FailureIcon() string
- func Input(msg string, def string) (res string)
- func NewSpinner() *spinner.Spinner
- func OnFormatChange(ls ...FmtChangeListener)
- func Pwd(msg string) (res string)
- func Query(r graph.Request) error
- func SetFormatter(i any, f formatter.Func)
- func SuccessIcon() string
- func TmplFileName(name string) string
- func WarningIcon() string
- func Write(i any)
- func WriteErr(err error)
- func WriteResult(rs []graph.Result) error
- type FmtChangeListener
- type FormatInfo
- type NamedTemplate
- type TmplMgr
Constants ¶
const TmplExt = ".tmpl"
TmplExt is the filename extension for templates.
Variables ¶
var CypherLexer = lexers.Register(MustNewLazyLexer( &Config{ Name: "Cypher", Aliases: []string{"cypher"}, Filenames: []string{"*.cyp", "*.cypher"}, MimeTypes: []string{}, CaseInsensitive: true, }, func() Rules { return Rules{ "root": { Include("comment"), Include("keywords"), Include("clauses"), Include("relations"), Include("strings"), Include("whitespace"), Include("barewords"), }, "comment": { {Pattern: `^.*//.*\n`, Type: CommentSingle}, }, "keywords": { {Pattern: `(create|order|match|limit|set|skip|start|return|with|where|delete|foreach|not|by|true|false)\b`, Type: Keyword}, }, "clauses": { {Pattern: `(all|any|as|asc|ascending|assert|call|case|create|create\s+index|create\s+unique|delete|desc|descending|distinct|drop\s+constraint\s+on|drop\s+index\s+on|end|ends\s+with|fieldterminator|foreach|in|is\s+node\s+key|is\s+null|is\s+unique|limit|load\s+csv\s+from|match|merge|none|not|null|on\s+match|on\s+create|optional\s+match|order\s+by|remove|return|set|skip|single|start|starts\s+with|then|union|union\s+all|unwind|using\s+periodic\s+commit|yield|where|when|with)\b`, Type: Keyword}, }, "relations": { {Pattern: `(-\[)(.*?)(\]->)`, Type: ByGroups(Operator, UsingSelf("root"), Operator)}, {Pattern: `(<-\[)(.*?)(\]-)`, Type: ByGroups(Operator, UsingSelf("root"), Operator)}, {Pattern: `(-\[)(.*?)(\]-)`, Type: ByGroups(Operator, UsingSelf("root"), Operator)}, {Pattern: `-->|<--|\[|\]`, Type: Operator}, {Pattern: `<|>|<>|=|<=|=>|\(|\)|\||:|,|;`, Type: Punctuation}, {Pattern: `[.*{}]`, Type: Punctuation}, }, "strings": { {Pattern: `"(?:\\[tbnrf\'"\\]|[^\\"])*"`, Type: LiteralString}, {Pattern: "`(?:``|[^`])+`", Type: NameVariable}, }, "whitespace": { {Pattern: `\s+`, Type: TextWhitespace}, }, "barewords": { {Pattern: `[a-z]\w*`, Type: Name}, {Pattern: `\d+`, Type: LiteralNumber}, }, } }, ))
CypherLexer highlights syntax tokens using Chroma.
var TmplDir = filepath.Join(internal.Must(os.UserConfigDir()), "persephone", "templates")
Functions ¶
func FailureIcon ¶
func FailureIcon() string
func NewSpinner ¶
NewSpinner creates a new default Spinner, which writes to stderr. Additional options can be set before it is started.
func OnFormatChange ¶
func OnFormatChange(ls ...FmtChangeListener)
func SetFormatter ¶
func SuccessIcon ¶
func SuccessIcon() string
func TmplFileName ¶
TmplFileName returns the basename of the template with the give name. This ensures that the returned name does not contain a file separator, and ends with the template file extension.
func WarningIcon ¶
func WarningIcon() string
func WriteErr ¶
func WriteErr(err error)
WriteErr formats the error message and writes it to stdout.
func WriteResult ¶
WriteResult outputs the Result using a formatting Writer.
Types ¶
type FmtChangeListener ¶
type FmtChangeListener func(i FormatInfo)
type FormatInfo ¶
type NamedTemplate ¶
type NamedTemplate struct { Name string `json:"Name" view:"Name" yaml:"Name"` Tmpl string `json:"Template" view:"Template" yaml:"Template"` Persistent bool `json:"Persistent" view:"Persistent" yaml:"Persistent"` }
NamedTemplate holds metadata of a template.
func (NamedTemplate) String ¶
func (t NamedTemplate) String() string
String returns the template name.
type TmplMgr ¶
TmplMgr loads and saves templates.
func GetTmplMgr ¶
func GetTmplMgr() *TmplMgr
GetTmplMgr returns the default template manager or creates a new one.
func NewTmplMgr ¶
func NewTmplMgr() *TmplMgr
NewTmplMgr creates a new template manager. It manages two transient and persistent templates. Persistent templates are stored in the filesystem at an absolute path.