Skip to content

Commit 00de6b9

Browse files
committed
switch defaults for issue view
1 parent c30b482 commit 00de6b9

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

command/issue.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func init() {
3939
issueListCmd.Flags().StringP("author", "A", "", "Filter by author")
4040

4141
issueCmd.AddCommand(issueViewCmd)
42-
issueViewCmd.Flags().BoolP("preview", "p", false, "Display preview of issue content")
42+
issueViewCmd.Flags().BoolP("web", "w", false, "Open issue in browser")
4343
}
4444

4545
var issueCmd = &cobra.Command{
@@ -233,17 +233,17 @@ func issueView(cmd *cobra.Command, args []string) error {
233233
}
234234
openURL := issue.URL
235235

236-
preview, err := cmd.Flags().GetBool("preview")
236+
web, err := cmd.Flags().GetBool("web")
237237
if err != nil {
238238
return err
239239
}
240240

241-
if preview {
242-
out := colorableOut(cmd)
243-
return printIssuePreview(out, issue)
244-
} else {
241+
if web {
245242
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", openURL)
246243
return utils.OpenInBrowser(openURL)
244+
} else {
245+
out := colorableOut(cmd)
246+
return printIssuePreview(out, issue)
247247
}
248248

249249
}

command/issue_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ func TestIssueList_disabledIssues(t *testing.T) {
212212
}
213213
}
214214

215-
func TestIssueView(t *testing.T) {
215+
func TestIssueView_web(t *testing.T) {
216216
initBlankContext("OWNER/REPO", "master")
217217
http := initFakeHTTP()
218218
http.StubRepoResponse("OWNER", "REPO")
@@ -231,7 +231,7 @@ func TestIssueView(t *testing.T) {
231231
})
232232
defer restoreCmd()
233233

234-
output, err := RunCommand(issueViewCmd, "issue view 123")
234+
output, err := RunCommand(issueViewCmd, "issue view -w 123")
235235
if err != nil {
236236
t.Errorf("error running command `issue view`: %v", err)
237237
}
@@ -246,7 +246,7 @@ func TestIssueView(t *testing.T) {
246246
eq(t, url, "https://github.com/OWNER/REPO/issues/123")
247247
}
248248

249-
func TestIssueView_numberArgWithHash(t *testing.T) {
249+
func TestIssueView_web_numberArgWithHash(t *testing.T) {
250250
initBlankContext("OWNER/REPO", "master")
251251
http := initFakeHTTP()
252252
http.StubRepoResponse("OWNER", "REPO")
@@ -265,7 +265,7 @@ func TestIssueView_numberArgWithHash(t *testing.T) {
265265
})
266266
defer restoreCmd()
267267

268-
output, err := RunCommand(issueViewCmd, "issue view \"#123\"")
268+
output, err := RunCommand(issueViewCmd, "issue view -w \"#123\"")
269269
if err != nil {
270270
t.Errorf("error running command `issue view`: %v", err)
271271
}
@@ -280,7 +280,7 @@ func TestIssueView_numberArgWithHash(t *testing.T) {
280280
eq(t, url, "https://github.com/OWNER/REPO/issues/123")
281281
}
282282

283-
func TestIssueView_preview(t *testing.T) {
283+
func TestIssueView(t *testing.T) {
284284
initBlankContext("OWNER/REPO", "master")
285285
http := initFakeHTTP()
286286
http.StubRepoResponse("OWNER", "REPO")
@@ -305,7 +305,7 @@ func TestIssueView_preview(t *testing.T) {
305305
} } } }
306306
`))
307307

308-
output, err := RunCommand(issueViewCmd, "issue view -p 123")
308+
output, err := RunCommand(issueViewCmd, "issue view 123")
309309
if err != nil {
310310
t.Errorf("error running command `issue view`: %v", err)
311311
}
@@ -326,7 +326,7 @@ func TestIssueView_preview(t *testing.T) {
326326
}
327327
}
328328

329-
func TestIssueView_previewWithEmptyBody(t *testing.T) {
329+
func TestIssueView_WithEmptyBody(t *testing.T) {
330330
initBlankContext("OWNER/REPO", "master")
331331
http := initFakeHTTP()
332332
http.StubRepoResponse("OWNER", "REPO")
@@ -351,7 +351,7 @@ func TestIssueView_previewWithEmptyBody(t *testing.T) {
351351
} } } }
352352
`))
353353

354-
output, err := RunCommand(issueViewCmd, "issue view -p 123")
354+
output, err := RunCommand(issueViewCmd, "issue view 123")
355355
if err != nil {
356356
t.Errorf("error running command `issue view`: %v", err)
357357
}
@@ -371,7 +371,7 @@ func TestIssueView_previewWithEmptyBody(t *testing.T) {
371371
}
372372
}
373373

374-
func TestIssueView_notFound(t *testing.T) {
374+
func TestIssueView_web_notFound(t *testing.T) {
375375
initBlankContext("OWNER/REPO", "master")
376376
http := initFakeHTTP()
377377

@@ -388,7 +388,7 @@ func TestIssueView_notFound(t *testing.T) {
388388
})
389389
defer restoreCmd()
390390

391-
_, err := RunCommand(issueViewCmd, "issue view 9999")
391+
_, err := RunCommand(issueViewCmd, "issue view -w 9999")
392392
if err == nil || err.Error() != "graphql error: 'Could not resolve to an Issue with the number of 9999.'" {
393393
t.Errorf("error running command `issue view`: %v", err)
394394
}
@@ -416,7 +416,7 @@ func TestIssueView_disabledIssues(t *testing.T) {
416416
}
417417
}
418418

419-
func TestIssueView_urlArg(t *testing.T) {
419+
func TestIssueView_web_urlArg(t *testing.T) {
420420
initBlankContext("OWNER/REPO", "master")
421421
http := initFakeHTTP()
422422
http.StubRepoResponse("OWNER", "REPO")
@@ -435,7 +435,7 @@ func TestIssueView_urlArg(t *testing.T) {
435435
})
436436
defer restoreCmd()
437437

438-
output, err := RunCommand(issueViewCmd, "issue view https://github.com/OWNER/REPO/issues/123")
438+
output, err := RunCommand(issueViewCmd, "issue view -w https://github.com/OWNER/REPO/issues/123")
439439
if err != nil {
440440
t.Errorf("error running command `issue view`: %v", err)
441441
}

0 commit comments

Comments
 (0)