Register registers the ghupdate plugin to the provided app instance.
(app core.App, rootCmd *cobra.Command, config Config)
| 70 | |
| 71 | // Register registers the ghupdate plugin to the provided app instance. |
| 72 | func Register(app core.App, rootCmd *cobra.Command, config Config) error { |
| 73 | p := &plugin{ |
| 74 | app: app, |
| 75 | currentVersion: rootCmd.Version, |
| 76 | config: config, |
| 77 | } |
| 78 | |
| 79 | if p.config.Owner == "" { |
| 80 | p.config.Owner = "pocketbase" |
| 81 | } |
| 82 | |
| 83 | if p.config.Repo == "" { |
| 84 | p.config.Repo = "pocketbase" |
| 85 | } |
| 86 | |
| 87 | if p.config.ArchiveExecutable == "" { |
| 88 | p.config.ArchiveExecutable = "pocketbase" |
| 89 | } |
| 90 | |
| 91 | if p.config.BaseURL == "" { |
| 92 | p.config.BaseURL = "https://api.github.com" |
| 93 | } else { |
| 94 | p.config.BaseURL = strings.TrimRight(p.config.BaseURL, "/") |
| 95 | } |
| 96 | |
| 97 | if p.config.HttpClient == nil { |
| 98 | p.config.HttpClient = http.DefaultClient |
| 99 | } |
| 100 | |
| 101 | if p.config.Context == nil { |
| 102 | p.config.Context = context.Background() |
| 103 | } |
| 104 | |
| 105 | rootCmd.AddCommand(p.updateCmd()) |
| 106 | |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | type plugin struct { |
| 111 | app core.App |
no test coverage detected
searching dependent graphs…