Detailed changes
@@ -25,7 +25,7 @@ func collabAddCommand() *cobra.Command {
Use: "add REPOSITORY USERNAME",
Short: "Add a collaborator to a repo",
Args: cobra.ExactArgs(2),
- PersistentPreRunE: checkIfAdmin,
+ PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, _ := fromContext(cmd)
repo := args[0]
@@ -43,7 +43,7 @@ func collabRemoveCommand() *cobra.Command {
Use: "remove REPOSITORY USERNAME",
Args: cobra.ExactArgs(2),
Short: "Remove a collaborator from a repo",
- PersistentPreRunE: checkIfAdmin,
+ PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, _ := fromContext(cmd)
repo := args[0]
@@ -10,12 +10,13 @@ func createCommand() *cobra.Command {
var private bool
var description string
var projectName string
+ var hidden bool
cmd := &cobra.Command{
Use: "create REPOSITORY",
Short: "Create a new repository",
Args: cobra.ExactArgs(1),
- PersistentPreRunE: checkIfAdmin,
+ PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, _ := fromContext(cmd)
name := args[0]
@@ -23,6 +24,7 @@ func createCommand() *cobra.Command {
Private: private,
Description: description,
ProjectName: projectName,
+ Hidden: hidden,
}); err != nil {
return err
}
@@ -33,6 +35,7 @@ func createCommand() *cobra.Command {
cmd.Flags().BoolVarP(&private, "private", "p", false, "make the repository private")
cmd.Flags().StringVarP(&description, "description", "d", "", "set the repository description")
cmd.Flags().StringVarP(&projectName, "name", "n", "", "set the project name")
+ cmd.Flags().BoolVarP(&hidden, "hidden", "H", false, "hide the repository from the list")
return cmd
}
@@ -8,7 +8,7 @@ func deleteCommand() *cobra.Command {
Aliases: []string{"del", "remove", "rm"},
Short: "Delete a repository",
Args: cobra.ExactArgs(1),
- PersistentPreRunE: checkIfAdmin,
+ PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, _ := fromContext(cmd)
name := args[0]
@@ -16,7 +16,7 @@ func importCommand() *cobra.Command {
Use: "import REPOSITORY REMOTE",
Short: "Import a new repository from remote",
Args: cobra.ExactArgs(2),
- PersistentPreRunE: checkIfAdmin,
+ PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
cfg, _ := fromContext(cmd)
name := args[0]
@@ -7,6 +7,8 @@ import (
// listCommand returns a command that list file or directory at path.
func listCommand() *cobra.Command {
+ var all bool
+
listCmd := &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
@@ -20,11 +22,16 @@ func listCommand() *cobra.Command {
}
for _, r := range repos {
if cfg.Backend.AccessLevelByPublicKey(r.Name(), s.PublicKey()) >= backend.ReadOnlyAccess {
- cmd.Println(r.Name())
+ if !r.IsHidden() || all {
+ cmd.Println(r.Name())
+ }
}
}
return nil
},
}
+
+ listCmd.Flags().BoolVarP(&all, "all", "a", false, "List all repositories")
+
return listCmd
}