Skip to content

Commit

Permalink
git: others description
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 22, 2022
1 parent 4d25053 commit 1d1d2c7
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 60 deletions.
53 changes: 53 additions & 0 deletions completers/git-clang-format_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/git"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "clang-format",
Short: "run clang-format on lines that differ",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().Bool("Cached,", false, "format lines in the stage instead of the working dir")
rootCmd.Flags().String("binary", "", "path to clang-format")
rootCmd.Flags().String("commit", "", "default commit to use if none is specified")
rootCmd.Flags().Bool("diff", false, "print a diff instead of applying the changes")
rootCmd.Flags().Bool("diffstat", false, "print a diffstat instead of applying the changes")
rootCmd.Flags().String("extensions", "", "comma-separated list of file extensions to format")
rootCmd.Flags().BoolP("force", "f", false, "allow changes to unstaged files")
rootCmd.Flags().BoolP("help", "h", false, "show this help message and exit")
rootCmd.Flags().BoolP("patch", "p", false, "select hunks interactively")
rootCmd.Flags().BoolP("quiet", "q", false, "print less information")
rootCmd.Flags().Bool("staged,", false, "format lines in the stage instead of the working dir")
rootCmd.Flags().String("style", "", "passed to clang-format")
rootCmd.Flags().BoolP("verbose", "v", false, "print extra information")

// TODO flag completion
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"binary": carapace.ActionFiles(),
"commit": git.ActionRefs(git.RefOption{}.Default()),
})

carapace.Gen(rootCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if rootCmd.Flags().ArgsLenAtDash() != -1 {
return carapace.ActionFiles()
}

if diff := rootCmd.Flag("diff").Changed; len(c.Args) == 0 || (len(c.Args) == 1 && diff) {
return git.ActionRefs(git.RefOption{}.Default())
}
return carapace.ActionFiles()
}),
)
}
7 changes: 7 additions & 0 deletions completers/git-clang-format_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/git-clang-format_completer/cmd"

func main() {
cmd.Execute()
}
42 changes: 0 additions & 42 deletions completers/git_completer/cmd/clangFormat.go

This file was deleted.

17 changes: 0 additions & 17 deletions completers/git_completer/cmd/crypt_generated.go

This file was deleted.

81 changes: 80 additions & 1 deletion completers/git_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func addOtherCommands() {
for _, name := range lines[:len(lines)-1] {
pluginCmd := &cobra.Command{
Use: name,
Short: "",
Short: othersDescription(name),
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}
Expand All @@ -130,3 +130,82 @@ func addOtherCommands() {
}
}
}

func othersDescription(name string) string {
return map[string]string{
"abort": "Abort current git operation",
"alias": "Define, search and show aliases",
"archive-file": "Export the current HEAD of the git repository to an archive",
"authors": "Generate authors report",
"browse": "View the web page for the current repository",
"browse-ci": "Opens the current git repository CI page in your default web browser",
"brv": "List branches sorted by their last commit date",
"bulk": "Run git commands on multiple repositories",
"changelog": "Generate a changelog report",
"clang-format": "run clang-format on lines that differ",
"clear": "Rigorously clean up a repository",
"clear-soft": "Soft clean up a repository",
"coauthor": "Add a co-author to the last commit",
"commits-since": "Show commit logs since some date",
"contrib": "Show user's contributions",
"count": "Show commit count",
"cp": "Copy a file keeping its history",
"create-branch": "Create branches",
"delete-branch": "Delete branches",
"delete-merged-branches": "Delete merged branches",
"delete-squashed-branches": "Delete branches that were squashed",
"delete-submodule": "Delete submodules",
"delete-tag": "Delete tags",
"delta": "Lists changed files",
"effort": "Show effort statistics on file(s)",
"extras": "Awesome GIT utilities",
"feature": "Create/Merge feature branch",
"force-clone": "overwrite local repositories with clone",
"fork": "Fork a repo on github",
"fresh-branch": "Create fresh branches",
"gh-pages": "Create the GitHub Pages branch",
"graft": "Merge and destroy a given branch",
"guilt": "calculate change between two revisions",
"ignore": "Add .gitignore patterns",
"ignore-io": "Get sample gitignore file",
"info": "Returns information on current repository",
"local-commits": "List local commits",
"lock": "Lock a file excluded from version control",
"locked": "ls files that have been locked",
"magic": "Automate add/commit/push routines",
"merge-into": "Merge one branch into another",
"merge-repo": "Merge two repo histories",
"missing": "Show commits missing from another branch",
"mr": "Checks out a merge request locally",
"obliterate": "rewrite past commits to remove some files",
"paste": "Send patches to pastebin for chat conversations",
"pr": "Checks out a pull request locally",
"psykorebase": "Rebase a branch with a merge commit",
"pull-request": "Create pull request for GitHub project",
"reauthor": "Rewrite history to change author's identity",
"rebase-patch": "Rebases a patch",
"release": "Commit, tag and push changes to the repository",
"rename-branch": "rename local branch and push to remote",
"rename-remote": "Rename a remote",
"rename-tag": "Rename a tag",
"repl": "git read-eval-print-loop",
"reset-file": "Reset one file",
"root": "show path of root",
"rscp": "Copies specific files from the working directory of a remote repository to the current working directory.",
"scp": "Copy files to SSH compatible git-remote",
"sed": "replace patterns in git-controlled files",
"setup": "Set up a git repository",
"show-merged-branches": "Show merged branches",
"show-tree": "show branch tree of commit history",
"show-unmerged-branches": "Show unmerged branches",
"squash": "squash N last changes up to a ref'ed commit",
"stamp": "Stamp the last commit message",
"standup": "Recall the commit history",
"summary": "Show repository summary",
"sync": "Sync local branch with remote branch",
"touch": "Touch and add file to the index",
"undo": "Remove latest commits",
"unlock": "Unlock a file excluded from version control",
"utimes": "Change files modification time to their last commit date",
}[name]
}

0 comments on commit 1d1d2c7

Please sign in to comment.