Skip to content

Commit

Permalink
Merge pull request #191 from rsteube/add-git-init-and-rm
Browse files Browse the repository at this point in the history
added git init and rm
  • Loading branch information
rsteube authored Oct 25, 2020
2 parents d3c1bf7 + 4867a96 commit 52bc138
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 26 deletions.
44 changes: 44 additions & 0 deletions completers/git_completer/cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var initCmd = &cobra.Command{
Use: "init",
Short: "Create an empty Git repository or reinitialize an existing one",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(initCmd).Standalone()

initCmd.Flags().Bool("bare", false, "create a bare repository")
initCmd.Flags().StringP("initial-branch", "b", "", "override the name of the initial branch")
initCmd.Flags().String("object-format", "", "specify the hash algorithm to use")
initCmd.Flags().BoolP("quiet", "q", false, "be quiet")
initCmd.Flags().String("separate-git-dir", "", "separate git dir from working tree")
initCmd.Flags().String("shared", "", "specify that the git repository is to be shared amongst several users")
initCmd.Flags().String("template", "", "directory from which templates will be used")
rootCmd.AddCommand(initCmd)

initCmd.Flag("shared").NoOptDefVal = "umask"

carapace.Gen(initCmd).FlagCompletion(carapace.ActionMap{
"object-format": carapace.ActionValues("sha1", "sha256"),
"separate-git-dir": carapace.ActionFiles(""),
"shared": carapace.ActionValuesDescribed(
"false", "use permissions reported by umask",
"true", "make the repository group-writable",
"umask", "use permissions reported by umask",
"group", "make the repository group-writable",
"all", "make repository readable by all users",
"world", "make repository readable by all users",
"everybody", "make repository readable by all users",
),
"template": carapace.ActionDirectories(),
})

carapace.Gen(initCmd).PositionalCompletion(carapace.ActionFiles(""))
}
21 changes: 0 additions & 21 deletions completers/git_completer/cmd/init_generated.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var rmCmd = &cobra.Command{
Use: "rm",
Short: "Remove files from the working tree and from the index",
Run: func(cmd *cobra.Command, args []string) {
},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(rmCmd).Standalone()

rmCmd.Flags().BoolS("r", "r", false, "allow recursive removal")
rmCmd.Flags().Bool("cached", false, "only remove from the index")
rmCmd.Flags().BoolP("dry-run", "n", false, "dry run")
rmCmd.Flags().BoolP("force", "f", false, "override the up-to-date check")
rmCmd.Flags().Bool("ignore-unmatch", false, "exit with a zero status even if nothing matched")
rmCmd.Flags().BoolP("dry-run", "n", false, "dry run")
rmCmd.Flags().Bool("pathspec-file-nul", false, "with --pathspec-from-file, pathspec elements are separated with NUL character")
rmCmd.Flags().Bool("pathspec-file-nul", false, "pathspec elements are separated with NUL character")
rmCmd.Flags().String("pathspec-from-file", "", "read pathspec from file")
rmCmd.Flags().BoolP("quiet", "q", false, "do not list removed files")
rmCmd.Flags().BoolS("r", "r", false, "allow recursive removal")
rootCmd.AddCommand(rmCmd)

carapace.Gen(rmCmd).FlagCompletion(carapace.ActionMap{
"pathspec-from-file": carapace.ActionFiles(""),
})

carapace.Gen(rmCmd).PositionalAnyCompletion(carapace.ActionFiles(""))
}

0 comments on commit 52bc138

Please sign in to comment.