This commit is contained in:
27
cmd/raw.go
27
cmd/raw.go
@ -17,7 +17,7 @@ var (
|
||||
branch string
|
||||
)
|
||||
|
||||
var rawCmd = &cobra.Command{
|
||||
var RawCmd = &cobra.Command{
|
||||
Use: "raw",
|
||||
Short: "Get the content of the specified file in the repository.",
|
||||
Long: `Get the content of the specified file in the repository and save it locally.`,
|
||||
@ -43,17 +43,16 @@ var rawCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
rawCmd.Flags().StringVarP(&pid, "project-id", "p", "1", "The project id.")
|
||||
rawCmd.Flags().StringVarP(&token, "token", "t", "", "The token of gitlab.")
|
||||
rawCmd.Flags().StringVarP(&url, "url", "u", "", "The url of gitlab.")
|
||||
rawCmd.Flags().StringVarP(&getFilePath, "getfile-path", "g", "", "The getfile path.")
|
||||
rawCmd.Flags().StringVarP(&outputfilePath, "outputfile-path", "o", "", "The outputfile path.")
|
||||
rawCmd.Flags().StringVarP(&branch, "branch", "b", "main", "The project branch of gitlab.")
|
||||
rawCmd.MarkFlagRequired("project-id")
|
||||
rawCmd.MarkFlagRequired("token")
|
||||
rawCmd.MarkFlagRequired("url")
|
||||
rawCmd.MarkFlagRequired("outputfile-path")
|
||||
rawCmd.MarkFlagRequired("getfile-path")
|
||||
rawCmd.MarkFlagRequired("branch")
|
||||
|
||||
RawCmd.Flags().StringVarP(&pid, "project-id", "p", "1", "The project id.")
|
||||
RawCmd.Flags().StringVarP(&token, "token", "t", "", "The token of gitlab.")
|
||||
RawCmd.Flags().StringVarP(&url, "url", "u", "", "The url of gitlab.")
|
||||
RawCmd.Flags().StringVarP(&getFilePath, "getfile-path", "g", "", "The getfile path.")
|
||||
RawCmd.Flags().StringVarP(&outputfilePath, "outputfile-path", "o", "", "The outputfile path.")
|
||||
RawCmd.Flags().StringVarP(&branch, "branch", "b", "main", "The project branch of gitlab.")
|
||||
RawCmd.MarkFlagRequired("project-id")
|
||||
RawCmd.MarkFlagRequired("token")
|
||||
RawCmd.MarkFlagRequired("url")
|
||||
RawCmd.MarkFlagRequired("outputfile-path")
|
||||
RawCmd.MarkFlagRequired("getfile-path")
|
||||
RawCmd.MarkFlagRequired("branch")
|
||||
}
|
||||
|
30
cmd/root.go
30
cmd/root.go
@ -1,30 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "cdglab",
|
||||
Short: "cdglab is a tool for gitlab CI-CD.",
|
||||
Long: `cdglab is a basic tool for Gitlab CI/CD, used to encapsulate a series of RESTful API calls.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Execute the command cdglab -h to view the usage method.")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand()
|
||||
rootCmd.AddCommand(rawCmd)
|
||||
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user