@@ -14,7 +14,6 @@ import (
1414 "github.com/cli/cli/git"
1515 "github.com/cli/cli/internal/ghrepo"
1616 "github.com/cli/cli/pkg/githubtemplate"
17- "github.com/cli/cli/pkg/text"
1817 "github.com/cli/cli/utils"
1918 "github.com/spf13/cobra"
2019 "github.com/spf13/pflag"
@@ -23,7 +22,6 @@ import (
2322func init () {
2423 RootCmd .AddCommand (issueCmd )
2524 issueCmd .AddCommand (issueStatusCmd )
26- issueCmd .AddCommand (issueViewCmd )
2725
2826 issueCmd .AddCommand (issueCreateCmd )
2927 issueCreateCmd .Flags ().StringP ("title" , "t" , "" ,
@@ -39,6 +37,7 @@ func init() {
3937 issueListCmd .Flags ().IntP ("limit" , "L" , 30 , "Maximum number of issues to fetch" )
4038 issueListCmd .Flags ().StringP ("author" , "A" , "" , "Filter by author" )
4139
40+ issueCmd .AddCommand (issueViewCmd )
4241 issueViewCmd .Flags ().BoolP ("preview" , "p" , false , "Display preview of issue content" )
4342}
4443
@@ -67,7 +66,7 @@ var issueStatusCmd = &cobra.Command{
6766 RunE : issueStatus ,
6867}
6968var issueViewCmd = & cobra.Command {
70- Use : "view {<number> | <url> | <branch> }" ,
69+ Use : "view {<number> | <url>}" ,
7170 Args : func (cmd * cobra.Command , args []string ) error {
7271 if len (args ) < 1 {
7372 return FlagError {errors .New ("issue number or URL required as argument" )}
@@ -138,23 +137,7 @@ func issueList(cmd *cobra.Command, args []string) error {
138137 }
139138
140139 out := cmd .OutOrStdout ()
141- table := utils .NewTablePrinter (out )
142- for _ , issue := range issues {
143- issueNum := strconv .Itoa (issue .Number )
144- if table .IsTTY () {
145- issueNum = "#" + issueNum
146- }
147- labels := labelList (issue )
148- if labels != "" && table .IsTTY () {
149- labels = fmt .Sprintf ("(%s)" , labels )
150- }
151- table .AddField (issueNum , nil , colorFuncForState (issue .State ))
152- table .AddField (replaceExcessiveWhitespace (issue .Title ), nil , nil )
153- table .AddField (labels , nil , utils .Gray )
154- table .EndRow ()
155- }
156- table .Render ()
157-
140+ printIssues (out , "" , len (issues ), issues )
158141 return nil
159142}
160143
@@ -358,7 +341,7 @@ func issueCreate(cmd *cobra.Command, args []string) error {
358341 interactive := title == "" || body == ""
359342
360343 if interactive {
361- tb , err := titleBodySurvey (cmd , title , body , templateFiles )
344+ tb , err := titleBodySurvey (cmd , title , body , defaults {}, templateFiles )
362345 if err != nil {
363346 return fmt .Errorf ("could not collect title and/or body: %w" , err )
364347 }
@@ -409,21 +392,26 @@ func issueCreate(cmd *cobra.Command, args []string) error {
409392}
410393
411394func printIssues (w io.Writer , prefix string , totalCount int , issues []api.Issue ) {
395+ table := utils .NewTablePrinter (w )
412396 for _ , issue := range issues {
413- number := utils .Green ("#" + strconv .Itoa (issue .Number ))
414- coloredLabels := labelList (issue )
415- if coloredLabels != "" {
416- coloredLabels = utils .Gray (fmt .Sprintf (" (%s)" , coloredLabels ))
397+ issueNum := strconv .Itoa (issue .Number )
398+ if table .IsTTY () {
399+ issueNum = "#" + issueNum
400+ }
401+ issueNum = prefix + issueNum
402+ labels := labelList (issue )
403+ if labels != "" && table .IsTTY () {
404+ labels = fmt .Sprintf ("(%s)" , labels )
417405 }
418-
419406 now := time .Now ()
420407 ago := now .Sub (issue .UpdatedAt )
421-
422- fmt . Fprintf ( w , "%s%s %s%s %s \n " , prefix , number ,
423- text . Truncate ( 70 , replaceExcessiveWhitespace ( issue . Title )),
424- coloredLabels ,
425- utils . Gray ( utils . FuzzyAgo ( ago )) )
408+ table . AddField ( issueNum , nil , colorFuncForState ( issue . State ))
409+ table . AddField ( replaceExcessiveWhitespace ( issue . Title ), nil , nil )
410+ table . AddField ( labels , nil , utils . Gray )
411+ table . AddField ( utils . FuzzyAgo ( ago ), nil , utils . Gray )
412+ table . EndRow ( )
426413 }
414+ table .Render ()
427415 remaining := totalCount - len (issues )
428416 if remaining > 0 {
429417 fmt .Fprintf (w , utils .Gray ("%sAnd %d more\n " ), prefix , remaining )
0 commit comments