feat: v0.3.0d — add PR checks, iostreams, aliases, and broad enhancements

Add PR checks command, iostreams/text packages for colored table output,
top-level run/workflow aliases matching gh CLI structure. Enhance actions,
issues, PRs, releases, repos, labels, milestones, and wiki commands with
improved flags, JSON output, and error handling.
This commit is contained in:
sid 2026-03-23 11:42:44 -06:00
parent 7c0dcc8696
commit 113505de95
29 changed files with 3131 additions and 542 deletions

View file

@ -171,8 +171,10 @@ func runAPI(cmd *cobra.Command, args []string) error {
}
// Execute request
ios.StartSpinner("Requesting...")
httpClient := &http.Client{}
resp, err := httpClient.Do(req)
ios.StopSpinner()
if err != nil {
return fmt.Errorf("failed to perform request: %w", err)
}
@ -180,13 +182,13 @@ func runAPI(cmd *cobra.Command, args []string) error {
// Print response headers if requested
if include {
fmt.Fprintf(os.Stdout, "%s %s\n", resp.Proto, resp.Status)
fmt.Fprintf(ios.Out, "%s %s\n", resp.Proto, resp.Status)
for key, values := range resp.Header {
for _, v := range values {
fmt.Fprintf(os.Stdout, "%s: %s\n", key, v)
fmt.Fprintf(ios.Out, "%s: %s\n", key, v)
}
}
fmt.Fprintln(os.Stdout)
fmt.Fprintln(ios.Out)
}
// Read response body
@ -198,12 +200,12 @@ func runAPI(cmd *cobra.Command, args []string) error {
// Handle non-2xx status codes
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
if !silent {
fmt.Fprint(os.Stderr, string(respBody))
fmt.Fprint(ios.ErrOut, string(respBody))
if len(respBody) > 0 && respBody[len(respBody)-1] != '\n' {
fmt.Fprintln(os.Stderr)
fmt.Fprintln(ios.ErrOut)
}
}
os.Exit(1)
return fmt.Errorf("API request failed with status %d", resp.StatusCode)
}
if silent || len(respBody) == 0 {
@ -215,14 +217,14 @@ func runAPI(cmd *cobra.Command, args []string) error {
if strings.Contains(contentType, "json") || json.Valid(respBody) {
var parsed any
if err := json.Unmarshal(respBody, &parsed); err == nil {
enc := json.NewEncoder(os.Stdout)
enc := json.NewEncoder(ios.Out)
enc.SetIndent("", " ")
return enc.Encode(parsed)
}
}
// Raw output for non-JSON responses
_, err = os.Stdout.Write(respBody)
_, err = ios.Out.Write(respBody)
return err
}