mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
refactor: add git generator for add
Signed-off-by: cpendery <cpendery@vt.edu>
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/cpendery/clac/autocomplete/generators"
|
||||
"github.com/cpendery/clac/autocomplete/model"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func CommitMessageGenerator() *model.Generator {
|
||||
@@ -23,3 +26,30 @@ func CommitMessageGenerator() *model.Generator {
|
||||
"\n",
|
||||
)
|
||||
}
|
||||
|
||||
func AddFileGenerator() *model.Generator {
|
||||
return &model.Generator{
|
||||
Id: uuid.New(),
|
||||
Script: "git --no-optional-locks status --short",
|
||||
PostProcess: func(s string) []model.TermSuggestion {
|
||||
suggestions := []model.TermSuggestion{}
|
||||
lines := strings.Split(s, "\n")
|
||||
for _, line := range lines {
|
||||
baseRune := strings.IndexRune(line, 0)
|
||||
if baseRune == 'M' || baseRune == 'A' {
|
||||
continue
|
||||
}
|
||||
splits := strings.Split(line, " ")
|
||||
if len(splits) <= 1 {
|
||||
continue
|
||||
}
|
||||
filename := splits[len(splits)-1]
|
||||
suggestions = append(suggestions, model.TermSuggestion{
|
||||
Name: filename,
|
||||
Description: "Unstaged/Untracked File",
|
||||
})
|
||||
}
|
||||
return suggestions
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2755,7 +2755,7 @@ func init() {
|
||||
Description: `Add file contents to the index`,
|
||||
Args: []model.Arg{{
|
||||
Name: "pathspec",
|
||||
Generator: nil, // TODO: port over generator
|
||||
Generator: git.AddFileGenerator(),
|
||||
IsOptional: true,
|
||||
IsVariadic: true,
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user