forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
complete_redir.go
33 lines (28 loc) · 864 Bytes
/
complete_redir.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package completion
import (
"github.com/u-root/u-root/cmds/core/elvish/parse"
)
type redirComplContext struct {
complContextCommon
}
func (*redirComplContext) name() string { return "redir" }
func findRedirComplContext(n parse.Node, ev pureEvaler) complContext {
if parse.IsSep(n) {
if parse.IsRedir(n.Parent()) {
return &redirComplContext{complContextCommon{
"", quotingForEmptySeed, n.End(), n.End()}}
}
}
if primary, ok := n.(*parse.Primary); ok {
if compound, seed := primaryInSimpleCompound(primary, ev); compound != nil {
if parse.IsRedir(compound.Parent()) {
return &redirComplContext{complContextCommon{
seed, primary.Type, compound.Begin(), compound.End()}}
}
}
}
return nil
}
func (ctx *redirComplContext) generate(env *complEnv, ch chan<- rawCandidate) error {
return complFilenameInner(ctx.seed, false, ch)
}