Skip to content

Commit

Permalink
fix file suggestions for app entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
runz0rd committed Sep 21, 2023
1 parent 027115d commit e8650e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c AttachConfig) MarshalYAML() (interface{}, error) {

func (c AttachConfig) SourcePathSuggest(d prompt.Document) []prompt.Suggest {
return suggest.Completer(d, suggest.MustList(func() ([]string, error) {
return find(".", "-type", "f", "-name", "main.go")
return findContaining("package main", ".", "-type", "f", "-name", "*.go")
}))
}

Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ func loadYaml(path string, data interface{}) error {
func find(args ...string) ([]string, error) {
return script.Exec(fmt.Sprintf("find %v", strings.Join(args, " "))).Slice()
}

func findContaining(v string, args ...string) ([]string, error) {
return script.Exec(fmt.Sprintf("find %v -exec grep -lr %q {} +", strings.Join(args, " "), v)).Slice()
}
2 changes: 1 addition & 1 deletion config/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c PatchConfig) MarshalYAML() (interface{}, error) {

func (c PatchConfig) SourcePathSuggest(d prompt.Document) []prompt.Suggest {
return suggest.Completer(d, suggest.MustList(func() ([]string, error) {
return find(".", "-type", "f", "-name", "main.go")
return findContaining("package main", ".", "-type", "f", "-name", "*.go")
}))
}

Expand Down

0 comments on commit e8650e8

Please sign in to comment.