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:
parent
7c0dcc8696
commit
113505de95
29 changed files with 3131 additions and 542 deletions
25
cmd/auth.go
25
cmd/auth.go
|
|
@ -68,7 +68,7 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
|
|||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
if hostname == "" {
|
||||
fmt.Print("Forgejo instance hostname (default: codeberg.org): ")
|
||||
fmt.Fprint(ios.ErrOut, "Forgejo instance hostname (default: codeberg.org): ")
|
||||
input, _ := reader.ReadString('\n')
|
||||
hostname = strings.TrimSpace(input)
|
||||
if hostname == "" {
|
||||
|
|
@ -77,12 +77,12 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
if token == "" {
|
||||
fmt.Print("Personal access token: ")
|
||||
fmt.Fprint(ios.ErrOut, "Personal access token: ")
|
||||
tokenBytes, err := term.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read token: %w", err)
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Fprintln(ios.ErrOut)
|
||||
token = strings.TrimSpace(string(tokenBytes))
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,9 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
|
|||
return fmt.Errorf("failed to create client: %w", err)
|
||||
}
|
||||
|
||||
ios.StartSpinner("Authenticating...")
|
||||
user, _, err := client.GetMyUserInfo()
|
||||
ios.StopSpinner()
|
||||
if err != nil {
|
||||
return fmt.Errorf("authentication failed: %w", err)
|
||||
}
|
||||
|
|
@ -116,7 +118,8 @@ func runAuthLogin(cmd *cobra.Command, args []string) error {
|
|||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("✓ Authenticated as %s on %s\n", user.UserName, hostname)
|
||||
cs := ios.ColorScheme()
|
||||
fmt.Fprintf(ios.Out, "%s Authenticated as %s on %s\n", cs.SuccessIcon(), user.UserName, hostname)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -128,14 +131,15 @@ func runAuthStatus(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
if len(cfg.Hosts) == 0 {
|
||||
fmt.Println("Not authenticated with any Forgejo instances")
|
||||
fmt.Println("Run 'fgj auth login' to authenticate")
|
||||
fmt.Fprintln(ios.Out, "Not authenticated with any Forgejo instances")
|
||||
fmt.Fprintln(ios.Out, "Run 'fgj auth login' to authenticate")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println("Authenticated instances:")
|
||||
fmt.Fprintln(ios.Out, "Authenticated instances:")
|
||||
for hostname, host := range cfg.Hosts {
|
||||
fmt.Printf(" • %s (user: %s)\n", hostname, host.User)
|
||||
cs := ios.ColorScheme()
|
||||
fmt.Fprintf(ios.Out, " %s %s (user: %s)\n", cs.SuccessIcon(), hostname, host.User)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -158,7 +162,8 @@ func runAuthLogout(cmd *cobra.Command, args []string) error {
|
|||
return fmt.Errorf("failed to save config: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("✓ Logged out from %s\n", resolved)
|
||||
cs := ios.ColorScheme()
|
||||
fmt.Fprintf(ios.Out, "%s Logged out from %s\n", cs.SuccessIcon(), resolved)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +179,7 @@ func runAuthToken(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Println(cfg.Hosts[resolved].Token)
|
||||
fmt.Fprintln(ios.Out, cfg.Hosts[resolved].Token)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue