{"modulePath":"github.com/wavetermdev/waveterm/wavesrv","version":"v0.7.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package shparse\n\n## Constants\n\n```go\nconst (\n\tCompTypeCommandMeta = \"command-meta\"\n\tCompTypeCommand     = \"command\"\n\tCompTypeArg         = \"command-arg\"\n\tCompTypeInvalid     = \"invalid\"\n\tCompTypeVar         = \"var\"\n\tCompTypeAssignment  = \"assignment\"\n\tCompTypeBasic       = \"basic\"\n\tCompTypeFile        = \"file\"\n\tCompTypeDir         = \"dir\"\n)\n```\n\n```go\nconst (\n\tWordTypeRaw       = \"raw\"\n\tWordTypeLit       = \"lit\"  // (can-extend)\n\tWordTypeOp        = \"op\"   // single: \u0026 ; | ( ) \u003c \u003e \\n  multi(2): \u0026\u0026 || ;; \u003c\u003c \u003e\u003e \u003c\u0026 \u003e\u0026 \u003c\u003e \u003e| ((  multi(3): \u003c\u003c-    ('((' requires special processing)\n\tWordTypeKey       = \"key\"  // if then else elif fi do done case esac while until for in { } ! (( [[\n\tWordTypeGroup     = \"grp\"  // contains other words e.g. \"hello\"foo'bar'$x (has-subs) (can-extend)\n\tWordTypeSimpleVar = \"svar\" // simplevar $ (can-extend)\n\n\tWordTypeDQ       = \"dq\"   // \"    (quote-context) (can-extend) (has-subs)\n\tWordTypeDDQ      = \"ddq\"  // $\"   (can-extend) (has-subs) (for quotecontext, uses WordTypeDQ)\n\tWordTypeVarBrace = \"varb\" // ${   (quote-context) (can-extend) (internals not parsed)\n\tWordTypeDP       = \"dp\"   // $(   (quote-context) (has-subs)\n\tWordTypeBQ       = \"bq\"   // `    (quote-context) (has-subs)\n\n\tWordTypeSQ  = \"sq\"  // '     (can-extend)\n\tWordTypeDSQ = \"dsq\" // $'    (can-extend)\n\tWordTypeDPP = \"dpp\" // $((   (internals not parsed)\n\tWordTypePP  = \"pp\"  // ((    (internals not parsed)\n\tWordTypeDB  = \"db\"  // $[    (internals not parsed)\n)\n```\ncan-extend: WordTypeLit, WordTypeSimpleVar, WordTypeVarBrace, WordTypeDQ, WordTypeDDQ, WordTypeSQ, WordTypeDSQ\n\n```go\nconst (\n\tCmdTypeNone   = \"none\"   // holds control structures: '(' ')' 'for' 'while' etc.\n\tCmdTypeSimple = \"simple\" // holds real commands\n)\n```\n\n```go\nconst MaxExpandLen = 64 * 1024\n```\n\n## Functions\n\n```go\nfunc Extend(word *WordType, wordPos int, extStr string, complete bool) utilfn.StrWithPos\n```\nlit, grp, svar, dq, ddq, varb, sq, dsq\n\n```go\nfunc ResetWordOffsets(words []*WordType, startIdx int)\n```\n\n```go\nfunc SimpleVarNamePrefix(ectx ExpandContext, word *WordType, pos int) (string, bool)\n```\nreturns varname (no '$') and ok (whether this is a valid varname expansion)\n\n## Types\n\n```go\ntype CmdType struct {\n\tType            string\n\tAssignmentWords []*WordType\n\tWords           []*WordType\n\tNoneComplete    bool // set to true when last-word is a \"separator\"\n}\n```\n\n```go\nfunc ParseCommands(words []*WordType) []*CmdType\n```\n\n```go\ntype CompletionPos struct {\n\tRawPos      int // the raw position of cursor\n\tSuperOffset int // adjust all offsets in Cmd and CmdWord by SuperOffset\n\n\tCompType string   // see CompType* constants\n\tCmd      *CmdType // nil if between commands or a special completion (otherwise will be a SimpleCommand)\n\t// index into cmd.Words (only set when Cmd is not nil, otherwise we look at CompCommand)\n\t//   0 means command-word\n\t//   negative means assignment-words.\n\t//   can be past the end of Words (means start new word).\n\tCmdWordPos     int\n\tCompWord       *WordType // set to the word we are completing (nil if we are starting a new word)\n\tCompWordOffset int       // offset into compword (only if CmdWord is not nil)\n}\n```\n\n```go\nfunc FindCompletionPos(cmds []*CmdType, pos int) CompletionPos\n```\n\n```go\nfunc (cpos CompletionPos) Extend(origStr utilfn.StrWithPos, extensionStr string, extensionComplete bool) utilfn.StrWithPos\n```\n\n```go\ntype ExpandContext struct {\n\tHomeDir string\n}\n```\n\n```go\ntype ExpandInfo struct {\n\tHasTilde   bool // only ~ as the first character when SimpleExpandContext.HomeDir is set\n\tHasVar     bool // $x, $$, ${...}\n\tHasGlob    bool // *, ?, [, {\n\tHasExtGlob bool // ?(...) ... ?*+@!\n\tHasHistory bool // ! (anywhere)\n\tHasSpecial bool // subshell, arith\n}\n```\n\n```go\nfunc SimpleExpand(ectx ExpandContext, word *WordType) (string, ExpandInfo)\n```\n\n```go\nfunc SimpleExpandPrefix(ectx ExpandContext, word *WordType, pos int) (string, ExpandInfo)\n```\n\n```go\ntype QuoteContext []string\n```\n\n```go\ntype WordType struct {\n\tType     string\n\tOffset   int\n\tQC       QuoteContext\n\tRaw      []rune\n\tComplete bool\n\tPrefix   []rune\n\tSubs     []*WordType\n}\n```\n\n```go\nfunc CommandsToWords(cmds []*CmdType) []*WordType\n```\n\n```go\nfunc MakeEmptyWord(wtype string, qc QuoteContext, offset int, complete bool) *WordType\n```\n\n```go\nfunc Tokenize(cmd string) []*WordType\n```\n\n```go\nfunc (w *WordType) String() string\n```\n\n","path":"github.com/wavetermdev/waveterm/wavesrv/pkg/shparse","name":"shparse","synopsis":"","isRedistributable":true}
