@@ -35,7 +35,7 @@ func main() {
3535 var method string
3636 flag .StringVar (& method , "m" , "" , "Specify method to retrieve projects infos, available methods:\n " +
3737 " > -m projects\n " +
38- " > -m project -id PROJECT_ID\n " +
38+ " > -m project -id PROJECT_ID [-o <edit> -desc PROJECT_DESCRIPTION] \n " +
3939 " > -m hooks -id PROJECT_ID\n " +
4040 " > -m branches -id PROJECT_ID\n " +
4141 " > -m team -id PROJECT_ID\n " +
@@ -53,6 +53,12 @@ func main() {
5353 var sort string
5454 flag .StringVar (& sort , "sort" , "" , "Specify merge request sort" )
5555
56+ var operation string
57+ flag .StringVar (& operation , "o" , "" , "Specify operation" )
58+
59+ var desc string
60+ flag .StringVar (& desc , "desc" , "" , "Specify description" )
61+
5662 flag .Usage = func () {
5763 fmt .Printf ("Usage:\n " )
5864 flag .PrintDefaults ()
@@ -84,38 +90,56 @@ func main() {
8490 }
8591
8692 case "project" :
87- fmt .Println ("Fetching project…" )
8893
8994 if id == "" {
9095 flag .Usage ()
9196 return
9297 }
9398
94- project , err := gitlab .Project (id )
95- if err != nil {
96- fmt .Println (err .Error ())
97- return
99+ if operation == "" {
100+ fmt .Println ("Fetching project…" )
101+
102+ project , err := gitlab .Project (id )
103+ if err != nil {
104+ fmt .Println (err .Error ())
105+ return
106+ }
107+
108+ format := "> %-23s: %s\n "
109+
110+ fmt .Printf ("%s\n " , project .Name )
111+ fmt .Printf (format , "id" , strconv .Itoa (project .Id ))
112+ fmt .Printf (format , "name" , project .Name )
113+ fmt .Printf (format , "description" , project .Description )
114+ fmt .Printf (format , "default branch" , project .DefaultBranch )
115+ fmt .Printf (format , "owner.name" , project .Owner .Username )
116+ fmt .Printf (format , "public" , strconv .FormatBool (project .Public ))
117+ fmt .Printf (format , "path" , project .Path )
118+ fmt .Printf (format , "path with namespace" , project .PathWithNamespace )
119+ fmt .Printf (format , "issues enabled" , strconv .FormatBool (project .IssuesEnabled ))
120+ fmt .Printf (format , "merge requests enabled" , strconv .FormatBool (project .MergeRequestsEnabled ))
121+ fmt .Printf (format , "wall enabled" , strconv .FormatBool (project .WallEnabled ))
122+ fmt .Printf (format , "wiki enabled" , strconv .FormatBool (project .WikiEnabled ))
123+ fmt .Printf (format , "shared runners enabled" , strconv .FormatBool (project .SharedRunners ))
124+ fmt .Printf (format , "created at" , project .CreatedAtRaw )
125+ //fmt.Printf(format, "namespace", project.Namespace)
126+ }
127+
128+ switch operation {
129+ case "edit" :
130+ fmt .Println ("Edit project..." )
131+
132+ project := gogitlab.Project {
133+ Description : desc ,
134+ }
135+
136+ _ , err := gitlab .UpdateProject (id , & project )
137+ if err != nil {
138+ fmt .Println (err .Error ())
139+ return
140+ }
98141 }
99142
100- format := "> %-23s: %s\n "
101-
102- fmt .Printf ("%s\n " , project .Name )
103- fmt .Printf (format , "id" , strconv .Itoa (project .Id ))
104- fmt .Printf (format , "name" , project .Name )
105- fmt .Printf (format , "description" , project .Description )
106- fmt .Printf (format , "default branch" , project .DefaultBranch )
107- fmt .Printf (format , "owner.name" , project .Owner .Username )
108- fmt .Printf (format , "public" , strconv .FormatBool (project .Public ))
109- fmt .Printf (format , "path" , project .Path )
110- fmt .Printf (format , "path with namespace" , project .PathWithNamespace )
111- fmt .Printf (format , "issues enabled" , strconv .FormatBool (project .IssuesEnabled ))
112- fmt .Printf (format , "merge requests enabled" , strconv .FormatBool (project .MergeRequestsEnabled ))
113- fmt .Printf (format , "wall enabled" , strconv .FormatBool (project .WallEnabled ))
114- fmt .Printf (format , "wiki enabled" , strconv .FormatBool (project .WikiEnabled ))
115- fmt .Printf (format , "created at" , project .CreatedAtRaw )
116- fmt .Printf (format , "shared runners enabled" , strconv .FormatBool (project .SharedRunners ))
117- //fmt.Printf(format, "namespace", project.Namespace)
118-
119143 case "branches" :
120144 fmt .Println ("Fetching project branches…" )
121145
0 commit comments