@@ -28,7 +28,7 @@ type CardslistItem struct {
28
28
project * github.Project
29
29
}
30
30
31
- func Cleanup (c * clif.Command ) {
31
+ func Cleanup (c * clif.Command , out clif. Output ) {
32
32
client := login (c )
33
33
34
34
for _ , project := range getProjects (client ) {
@@ -38,32 +38,34 @@ func Cleanup(c *clif.Command) {
38
38
if card .GetColumnName () == "done" {
39
39
fmt .Println ("Archived" , card .GetNote (), "in" , project .GetName ())
40
40
archived := true
41
- client .Projects .UpdateProjectCard (ctx , card .GetID (), & github.ProjectCardOptions {Archived : & archived })
42
-
41
+ _ , _ , err := client .Projects .UpdateProjectCard (ctx , card .GetID (), & github.ProjectCardOptions {Archived : & archived })
42
+ if err == nil {
43
+ out .Printf ("\n <success> Archived <" + card .GetNote () + "> in <" + project .GetName () + "> project<reset>\n \n " )
44
+ }
43
45
}
44
46
}
45
47
46
48
}
47
49
}
48
50
49
- func CloseProject (c * clif.Command , in clif.Input ) {
51
+ func CloseProject (c * clif.Command , in clif.Input , out clif. Output ) {
50
52
client := login (c )
51
53
52
54
selectedProject := selectProject (client , in , c .Argument ("project" ).String ())
53
- /*
54
- if c.Argument("name").String() == "" {
55
- selectedProject = selectProject(client, in)
56
- }
57
- */
58
55
59
56
state := "closed"
60
- client .Projects .UpdateProject (ctx , selectedProject .GetID (), & github.ProjectOptions {State : & state })
57
+ project , _ , err := client .Projects .UpdateProject (ctx , selectedProject .GetID (), & github.ProjectOptions {State : & state })
58
+
59
+ if err == nil {
60
+ out .Printf ("\n <success> project <" + project .GetName () + "> has been sucessfully closed<reset>\n \n " )
61
+ }
61
62
}
62
- func OpenProject (c * clif.Command , in clif.Input ) {
63
+
64
+ func OpenProject (c * clif.Command , in clif.Input , out clif.Output ) {
63
65
_ , repo := GetGitdir ()
64
66
65
67
if repo == nil {
66
- OpenPersonalProject (c , in )
68
+ OpenPersonalProject (c , in , out )
67
69
} else {
68
70
space := "2"
69
71
@@ -77,21 +79,18 @@ func OpenProject(c *clif.Command, in clif.Input) {
77
79
})
78
80
}
79
81
if space == "1" {
80
- OpenPersonalProject (c , in )
82
+ OpenPersonalProject (c , in , out )
81
83
} else {
82
- OpenRepoProject (c , in , repo )
84
+ OpenRepoProject (c , in , out , repo )
83
85
}
84
86
}
85
87
}
86
88
87
- func OpenRepoProject (c * clif.Command , in clif.Input , repo * git.Repository ) {
89
+ func OpenRepoProject (c * clif.Command , in clif.Input , out clif. Output , repo * git.Repository ) {
88
90
client := login (c )
89
91
90
92
repositorydetails := getRepodetails (repo )
91
- /*
92
- fmt.Println("Owner: ", repositorydetails.owner)
93
- fmt.Println("Repositoryname:", repositorydetails.name)
94
- */
93
+
95
94
name := ""
96
95
if c .Argument ("project" ).String () != "" {
97
96
name = c .Argument ("project" ).String ()
@@ -108,12 +107,15 @@ func OpenRepoProject(c *clif.Command, in clif.Input, repo *git.Repository) {
108
107
}
109
108
project , _ , projectErr := client .Repositories .CreateProject (ctx , repositorydetails .owner , repositorydetails .name , & github.ProjectOptions {Name : & name , Body : & body , Public : & public })
110
109
if projectErr == nil {
111
- client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "open" })
112
- client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "done" })
110
+ _ , _ , openColumnErr := client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "open" })
111
+ _ , _ , doneColumnErr := client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "done" })
112
+ if projectErr == nil && openColumnErr == nil && doneColumnErr == nil {
113
+ out .Printf ("\n <success> project <" + project .GetName () + "> has been sucessfully opened<reset>\n \n " )
114
+ }
113
115
}
114
116
}
115
117
116
- func OpenPersonalProject (c * clif.Command , in clif.Input ) {
118
+ func OpenPersonalProject (c * clif.Command , in clif.Input , out clif. Output ) {
117
119
client := login (c )
118
120
119
121
name := ""
@@ -134,8 +136,11 @@ func OpenPersonalProject(c *clif.Command, in clif.Input) {
134
136
public = true
135
137
}
136
138
client .Projects .UpdateProject (ctx , project .GetID (), & github.ProjectOptions {Body : & body , Public : & public })
137
- client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "open" })
138
- client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "done" })
139
+ _ , _ , openColumnErr := client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "open" })
140
+ _ , _ , doneColumnErr := client .Projects .CreateProjectColumn (ctx , project .GetID (), & github.ProjectColumnOptions {Name : "done" })
141
+ if projectErr == nil && openColumnErr == nil && doneColumnErr == nil {
142
+ out .Printf ("\n <success> project <" + project .GetName () + "> has been sucessfully opened<reset>\n \n " )
143
+ }
139
144
}
140
145
141
146
}
@@ -156,7 +161,6 @@ func GetStatus(c *clif.Command, out clif.Output) []CardslistItem {
156
161
cards := getCards (client , project )
157
162
out .Printf ("\n <subline>List: " + project .GetName () + "<reset>\n " )
158
163
for _ , card := range cards {
159
- //fmt.Println(" <"+card.GetColumnName()+">", " ", card.GetNote())
160
164
out .Printf (strconv .Itoa (item ) + "| <" + card .GetColumnName () + "> " + card .GetNote () + "\n " )
161
165
cardslist = append (cardslist , CardslistItem {
162
166
id : item ,
@@ -174,11 +178,6 @@ func MoveCard(c *clif.Command, out clif.Output, in clif.Input) {
174
178
client := login (c )
175
179
176
180
selectedProject := selectProject (client , in , c .Argument ("project" ).String ())
177
- /*
178
- if c.Argument("project").String() == "" {
179
- selectedProject = selectProject(client, in)
180
- }
181
- */
182
181
183
182
var selectedCard * github.ProjectCard
184
183
if c .Option ("card" ).String () == "" {
@@ -198,17 +197,20 @@ func MoveCard(c *clif.Command, out clif.Output, in clif.Input) {
198
197
199
198
}
200
199
201
- func CreateCard (c * clif.Command , in clif.Input ) {
200
+ func CreateCard (c * clif.Command , in clif.Input , out clif. Output ) {
202
201
client := login (c )
203
202
204
203
selectedProject := selectProject (client , in , c .Argument ("project" ).String ())
205
204
206
205
projectColumns , _ , _ := client .Projects .ListProjectColumns (ctx , selectedProject .GetID (), nil )
207
- fmt .Println (projectColumns [0 ].GetID (), projectColumns [0 ].GetName ())
208
206
209
207
message := in .Ask ("What is the task" , nil )
210
- fmt .Println (message )
211
- client .Projects .CreateProjectCard (ctx , projectColumns [0 ].GetID (), & github.ProjectCardOptions {Note : message })
208
+
209
+ card , _ , cardErr := client .Projects .CreateProjectCard (ctx , projectColumns [0 ].GetID (), & github.ProjectCardOptions {Note : message })
210
+
211
+ if cardErr == nil {
212
+ out .Printf ("\n <success> added Card <" + card .GetNote () + "> sucessfully to <" + selectedProject .GetName () + "> project<reset>\n \n " )
213
+ }
212
214
213
215
}
214
216
func selectColumn (client * github.Client , in clif.Input , project * github.Project ) * github.ProjectColumn {
@@ -270,10 +272,7 @@ func getProjects(client *github.Client) []*github.Project {
270
272
271
273
if repo != nil {
272
274
repositorydetails := getRepodetails (repo )
273
- /*
274
- fmt.Println("Owner: ", repositorydetails.owner)
275
- fmt.Println("Repositoryname:", repositorydetails.name)
276
- */
275
+
277
276
repoprojects , _ , _ := client .Repositories .ListProjects (ctx , repositorydetails .owner , repositorydetails .name , nil )
278
277
279
278
userprojects = append (userprojects , repoprojects ... )
@@ -288,7 +287,6 @@ func getCards(client *github.Client, project *github.Project) []*github.ProjectC
288
287
projectColumns , _ , _ := client .Projects .ListProjectColumns (ctx , project .GetID (), nil )
289
288
290
289
for _ , column := range projectColumns {
291
- // fmt.Println(column.GetName())
292
290
cards , _ , _ := client .Projects .ListProjectCards (ctx , column .GetID (), nil )
293
291
294
292
for _ , card := range cards {
0 commit comments