| 
									
										
										
										
											2024-08-08 21:29:58 +08:00
										 |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"github.com/spf13/cobra" | 
					
						
							| 
									
										
										
										
											2024-08-09 14:57:41 +08:00
										 |  |  | 	"log" | 
					
						
							|  |  |  | 	"os" | 
					
						
							| 
									
										
										
										
											2024-08-08 21:29:58 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var updateCmd = &cobra.Command{ | 
					
						
							|  |  |  | 	Use:   "update", | 
					
						
							|  |  |  | 	Short: "更新项目", | 
					
						
							|  |  |  | 	Long:  `Update the current project`, | 
					
						
							|  |  |  | 	Run: func(cmd *cobra.Command, args []string) { | 
					
						
							| 
									
										
										
										
											2024-08-09 14:57:41 +08:00
										 |  |  | 		handleUpdateCommand(args) | 
					
						
							| 
									
										
										
										
											2024-08-08 21:29:58 +08:00
										 |  |  | 	}, | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-08-09 14:57:41 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | func init() { | 
					
						
							|  |  |  | 	initFlags(updateCmd) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func handleUpdateCommand(args []string) { | 
					
						
							|  |  |  | 	err := handleRemoteTemplate(template, branch, project) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		log.Printf("Error update project: %s\n", err) | 
					
						
							|  |  |  | 		os.Exit(1) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	fmt.Printf("Project %s update successfully!\n", project) | 
					
						
							|  |  |  | 	return | 
					
						
							|  |  |  | } |