| 60 | } |
| 61 | |
| 62 | func viewRun(opts *viewOptions) error { |
| 63 | repo, err := opts.BaseRepo() |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | |
| 68 | out := opts.IO.Out |
| 69 | cs := opts.IO.ColorScheme() |
| 70 | |
| 71 | autolink, err := opts.AutolinkClient.View(repo, opts.ID) |
| 72 | |
| 73 | if err != nil { |
| 74 | return fmt.Errorf("%s %w", cs.Red("error viewing autolink:"), err) |
| 75 | } |
| 76 | |
| 77 | if opts.Exporter != nil { |
| 78 | return opts.Exporter.Write(opts.IO, autolink) |
| 79 | } |
| 80 | |
| 81 | fmt.Fprintf(out, "Autolink in %s\n\n", cs.Bold(ghrepo.FullName(repo))) |
| 82 | |
| 83 | fmt.Fprint(out, cs.Bold("ID: ")) |
| 84 | fmt.Fprintln(out, cs.Cyanf("%d", autolink.ID)) |
| 85 | |
| 86 | fmt.Fprint(out, cs.Bold("Key Prefix: ")) |
| 87 | fmt.Fprintln(out, autolink.KeyPrefix) |
| 88 | |
| 89 | fmt.Fprint(out, cs.Bold("URL Template: ")) |
| 90 | fmt.Fprintln(out, autolink.URLTemplate) |
| 91 | |
| 92 | fmt.Fprint(out, cs.Bold("Alphanumeric: ")) |
| 93 | fmt.Fprintln(out, autolink.IsAlphanumeric) |
| 94 | |
| 95 | return nil |
| 96 | } |