add version
All checks were successful
Release / release (push) Successful in 5m56s

This commit is contained in:
2023-12-23 22:21:42 +08:00
parent e7ccda79ea
commit 209dd37cc1
6 changed files with 201 additions and 49 deletions

View File

@ -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")
}

View File

@ -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)
}
}