added fallback error, input what outputs origin

This commit is contained in:
daveberrys committed 2026-07-15 22:01:20 +08:00
1 parent 2c476b8d2a
commit b0836cdca8
1 file changed
+11 -3
+11 -3
View File
@@ -12,8 +12,16 @@ var linkRepoCmd = &cobra.Command{
Short: "Link a repository", Short: "Link a repository",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(c *cobra.Command, args []string) error { RunE: func(c *cobra.Command, args []string) error {
utils.RunGitSequence(false, []string{"remote", "set-url", "origin", args[0]}) switch args[0] {
fmt.Printf("Linked repository to: %s\n", args[0]) case "":
return nil return fmt.Errorf("repository URL cannot be empty")
case "what":
utils.RunGit(false, "remote", "get-url", "origin")
return nil
default:
utils.RunGitSequence(false, []string{"remote", "set-url", "origin", args[0]})
fmt.Printf("Linked repository to: %s\n", args[0])
return nil
}
}, },
} }