-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
65 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/git" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var helpCmd = &cobra.Command{ | ||
Use: "help", | ||
Short: "Display help information about Git", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
GroupID: groups[group_interrogator].ID, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(helpCmd).Standalone() | ||
|
||
helpCmd.Flags().BoolP("all", "a", false, "Prints all the available commands on the standard output") | ||
helpCmd.Flags().BoolP("config", "c", false, "List all available configuration variables") | ||
helpCmd.Flags().Bool("developer-interfaces", false, "Print list of file formats, protocols and other developer interfaces documentation") | ||
helpCmd.Flags().BoolP("guides", "g", false, "Prints a list of the Git concept guides on the standard output") | ||
helpCmd.Flags().BoolP("info", "i", false, "Display manual page for the command in the info format") | ||
helpCmd.Flags().BoolP("man", "m", false, "Display manual page for the command in the man format") | ||
helpCmd.Flags().Bool("no-aliases", false, "Exclude the listing of configured aliases") | ||
helpCmd.Flags().Bool("no-external-commands", false, "Exclude the listing of external \"git-*\" commands found in the $PATH") | ||
helpCmd.Flags().Bool("user-interfaces", false, "Prints a list of the repository, command and file interfaces documentation") | ||
helpCmd.Flags().Bool("verbose", false, "Print description for all recognized commands") | ||
helpCmd.Flags().BoolP("web", "w", false, "Display manual page for the command in the web (HTML) format") | ||
rootCmd.AddCommand(helpCmd) | ||
|
||
carapace.Gen(helpCmd).PositionalCompletion( | ||
carapace.Batch( | ||
carapace.ActionCommands(rootCmd), | ||
git.ActionDeveloperInterfaces(), | ||
).ToA(), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package git | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/rsteube/carapace" | ||
) | ||
|
||
// ActionDeveloperInterfaces completes developer interfaces | ||
// | ||
// format-bundle (The bundle file format) | ||
// format-chunk (Chunk-based file formats) | ||
func ActionDeveloperInterfaces() carapace.Action { | ||
return carapace.ActionExecCommand("git", "help", "--developer-interfaces")(func(output []byte) carapace.Action { | ||
lines := strings.Split(string(output), "\n") | ||
r := regexp.MustCompile(`^ (?P<interfaces>[^ ]+) +(?P<description>.*)$`) | ||
|
||
vals := make([]string, 0) | ||
for _, line := range lines { | ||
if matches := r.FindStringSubmatch(line); matches != nil { | ||
vals = append(vals, matches[1], matches[2]) | ||
} | ||
} | ||
return carapace.ActionValuesDescribed(vals...) | ||
}).Tag("developer interfaces") | ||
} |