Update formatting for autolink output
This commit is contained in:
parent
e4d720ba22
commit
b23cf6e8d7
3 changed files with 19 additions and 18 deletions
|
|
@ -109,9 +109,9 @@ func createRun(opts *createOptions) error {
|
|||
|
||||
cs := opts.IO.ColorScheme()
|
||||
fmt.Fprintf(opts.IO.Out,
|
||||
"%s Created repository autolink %d on %s\n",
|
||||
"%s Created repository autolink %s on %s\n",
|
||||
cs.SuccessIconWithColor(cs.Green),
|
||||
autolink.ID,
|
||||
cs.Cyanf("%d", autolink.ID),
|
||||
ghrepo.FullName(repo))
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -104,8 +104,10 @@ func listRun(opts *listOptions) error {
|
|||
|
||||
tp := tableprinter.New(opts.IO, tableprinter.WithHeader("ID", "KEY PREFIX", "URL TEMPLATE", "ALPHANUMERIC"))
|
||||
|
||||
cs := opts.IO.ColorScheme()
|
||||
|
||||
for _, autolink := range autolinks {
|
||||
tp.AddField(fmt.Sprintf("%d", autolink.ID))
|
||||
tp.AddField(cs.Cyanf("%d", autolink.ID))
|
||||
tp.AddField(autolink.KeyPrefix)
|
||||
tp.AddField(autolink.URLTemplate)
|
||||
tp.AddField(strconv.FormatBool(autolink.IsAlphanumeric))
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package view
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/internal/browser"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
"github.com/cli/cli/v2/pkg/cmd/repo/autolink/shared"
|
||||
|
|
@ -65,6 +64,8 @@ func viewRun(opts *viewOptions) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out := opts.IO.Out
|
||||
cs := opts.IO.ColorScheme()
|
||||
|
||||
autolink, err := opts.AutolinkClient.View(repo, opts.ID)
|
||||
|
|
@ -77,21 +78,19 @@ func viewRun(opts *viewOptions) error {
|
|||
return opts.Exporter.Write(opts.IO, autolink)
|
||||
}
|
||||
|
||||
msg := heredoc.Docf(`
|
||||
Autolink in %s
|
||||
fmt.Fprintf(out, "Autolink in %s\n\n", ghrepo.FullName(repo))
|
||||
|
||||
ID: %d
|
||||
Key Prefix: %s
|
||||
URL Template: %s
|
||||
Alphanumeric: %t
|
||||
`,
|
||||
ghrepo.FullName(repo),
|
||||
autolink.ID,
|
||||
autolink.KeyPrefix,
|
||||
autolink.URLTemplate,
|
||||
autolink.IsAlphanumeric,
|
||||
)
|
||||
fmt.Fprint(opts.IO.Out, msg)
|
||||
fmt.Fprint(out, cs.Bold("ID: "))
|
||||
fmt.Fprintln(out, cs.Cyanf("%d", autolink.ID))
|
||||
|
||||
fmt.Fprint(out, cs.Bold("Key Prefix: "))
|
||||
fmt.Fprintln(out, autolink.KeyPrefix)
|
||||
|
||||
fmt.Fprint(out, cs.Bold("URL Template: "))
|
||||
fmt.Fprintln(out, autolink.URLTemplate)
|
||||
|
||||
fmt.Fprint(out, cs.Bold("Alphanumeric: "))
|
||||
fmt.Fprintln(out, autolink.IsAlphanumeric)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue