Documentation
¶
Overview ¶
Package commands wires Cobra commands and delegates command workflows to internal modules.
Package commands provides the CLI commands for fotingo.
This file defines JSON output structures for all commands to support machine-readable output via the --json flag.
Index ¶
- Variables
- func Execute()
- func ExecuteWithExitCode() (exitCode int)
- func IsShellCompletionRequest() bool
- func OutputJSON(data interface{})
- func OutputJSONError(err error)
- func ShouldOutputDebug() bool
- func ShouldOutputJSON() bool
- func ShouldOutputVerbose() bool
- func ShouldSuppressOutput() bool
- type AISetupOutput
- type AISetupResult
- type BranchInfo
- type CommitInfo
- type ErrorOutput
- type GlobalFlags
- type InspectOutput
- type IssueInfo
- type JSONOutput
- type OpenOutput
- type PullRequestInfo
- type ReviewOutput
- type SearchOutput
- type SearchResultInfo
- type StartBranchInfo
- type StartOutput
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev" GitCommit = "unknown" BuildTime = "unknown" Platform = "unknown/unknown" )
Build metadata injected at release time via ldflags.
var Fotingo = &cobra.Command{ Use: "fotingo", Short: i18n.T(i18n.RootShort), Long: i18n.T(i18n.RootLong), SilenceUsage: true, SilenceErrors: true, }
var Global = GlobalFlags{}
Global holds the current global flags
Functions ¶
func Execute ¶
func Execute()
Execute runs the root command and handles exit codes. This is the main entry point for the CLI and should be called from main().
func ExecuteWithExitCode ¶
func ExecuteWithExitCode() (exitCode int)
ExecuteWithExitCode runs the root command and returns the exit code. This is useful for testing where os.Exit should not be called.
func IsShellCompletionRequest ¶
func IsShellCompletionRequest() bool
func OutputJSON ¶
func OutputJSON(data interface{})
OutputJSON outputs the data as formatted JSON to stdout. This is a convenience function that creates a new JSONOutput and writes.
func OutputJSONError ¶
func OutputJSONError(err error)
OutputJSONError outputs an error as JSON to stdout.
func ShouldOutputDebug ¶
func ShouldOutputDebug() bool
ShouldOutputDebug returns true when diagnostic output should be shown.
func ShouldOutputJSON ¶
func ShouldOutputJSON() bool
ShouldOutputJSON returns true if the --json flag is set. Commands should check this before outputting human-readable text.
func ShouldOutputVerbose ¶
func ShouldOutputVerbose() bool
ShouldOutputVerbose returns true when step-level progress should be shown.
func ShouldSuppressOutput ¶
func ShouldSuppressOutput() bool
ShouldSuppressOutput returns true if output should be suppressed. This is true when --quiet is set or when --json is set (to avoid mixing human-readable output with JSON).
Types ¶
type AISetupOutput ¶
type AISetupOutput struct {
Success bool `json:"success"`
Scope string `json:"scope,omitempty"`
Providers []string `json:"providers,omitempty"`
DryRun bool `json:"dryRun,omitempty"`
Force bool `json:"force,omitempty"`
Results []AISetupResult `json:"results,omitempty"`
Error string `json:"error,omitempty"`
}
AISetupOutput represents JSON output for `fotingo ai setup`.
type AISetupResult ¶
type AISetupResult struct {
Provider string `json:"provider"`
Scope string `json:"scope"`
Root string `json:"root"`
Path string `json:"path"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
}
AISetupResult captures one provider install outcome.
type BranchInfo ¶
type BranchInfo struct {
Name string `json:"name"`
IssueID string `json:"issueId,omitempty"`
DefaultBranch string `json:"defaultBranch,omitempty"`
}
BranchInfo contains information about a git branch
type CommitInfo ¶
type CommitInfo struct {
Hash string `json:"hash"`
Message string `json:"message"`
Author string `json:"author"`
}
CommitInfo contains information about a git commit
type ErrorOutput ¶
type ErrorOutput struct {
Error string `json:"error"`
Code int `json:"code,omitempty"`
Type string `json:"type,omitempty"`
}
ErrorOutput represents a JSON error response.
Example:
{
"error": "failed to create branch",
"code": 4,
"type": "Git error"
}
type GlobalFlags ¶
type GlobalFlags struct {
Branch string
Yes bool
JSON bool
Quiet bool
Verbose bool
Debug bool
NoColor bool
}
GlobalFlags holds the global flags available to all commands
type InspectOutput ¶
type InspectOutput struct {
Branch *BranchInfo `json:"branch,omitempty"`
Issue *IssueInfo `json:"issue,omitempty"`
IssueIDs []string `json:"issueIds,omitempty"`
Commits []CommitInfo `json:"commits,omitempty"`
}
InspectOutput represents the JSON output of the inspect command
type IssueInfo ¶
type IssueInfo struct {
Key string `json:"key"`
Summary string `json:"summary"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Type string `json:"type"`
ParentKey string `json:"parentKey,omitempty"`
EpicKey string `json:"epicKey,omitempty"`
URL string `json:"url"`
}
IssueInfo contains information about a Jira issue
type JSONOutput ¶
type JSONOutput struct {
// contains filtered or unexported fields
}
JSONOutput provides utilities for outputting JSON responses.
func NewJSONOutput ¶
func NewJSONOutput() *JSONOutput
NewJSONOutput creates a new JSONOutput that writes to stdout.
func (*JSONOutput) Write ¶
func (j *JSONOutput) Write(data interface{}) error
Write outputs data as formatted JSON to stdout.
func (*JSONOutput) WriteError ¶
func (j *JSONOutput) WriteError(err error) error
WriteError outputs an error as JSON.
func (*JSONOutput) WriteSuccess ¶
func (j *JSONOutput) WriteSuccess(data interface{}) error
WriteSuccess outputs a generic success response.
type OpenOutput ¶
type OpenOutput struct {
Success bool `json:"success"`
Target string `json:"target"`
URL string `json:"url,omitempty"`
Opened bool `json:"opened,omitempty"`
Error string `json:"error,omitempty"`
}
OpenOutput represents the JSON output of the open command.
Example success output:
{
"success": true,
"target": "pr",
"url": "https://github.com/owner/repo/pull/42",
"opened": true
}
type PullRequestInfo ¶
type PullRequestInfo struct {
Number int `json:"number"`
URL string `json:"url"`
Title string `json:"title"`
Draft bool `json:"draft"`
State string `json:"state"`
}
PullRequestInfo contains information about a GitHub pull request.
type ReviewOutput ¶
type ReviewOutput struct {
Success bool `json:"success"`
PullRequest *PullRequestInfo `json:"pullRequest,omitempty"`
Issue *IssueInfo `json:"issue,omitempty"`
Labels []string `json:"labels,omitempty"`
Reviewers []string `json:"reviewers,omitempty"`
TeamReviewers []string `json:"teamReviewers,omitempty"`
Assignees []string `json:"assignees,omitempty"`
Existed bool `json:"existed,omitempty"`
Error string `json:"error,omitempty"`
}
ReviewOutput represents the JSON output of the review command.
Example success output:
{
"success": true,
"pullRequest": {
"number": 42,
"url": "https://github.com/owner/repo/pull/42",
"title": "[PROJ-123] Fix login bug",
"draft": false,
"state": "open"
},
"issue": {
"key": "PROJ-123",
"summary": "Fix login bug",
"status": "In Review",
"type": "Bug",
"url": "https://jira.example.com/browse/PROJ-123"
},
"labels": ["bug", "priority"],
"reviewers": ["alice", "bob"],
"teamReviewers": ["acme/platform"],
"assignees": ["alice"]
}
Example when PR already exists:
{
"success": true,
"pullRequest": {
"number": 42,
"url": "https://github.com/owner/repo/pull/42",
"title": "[PROJ-123] Fix login bug",
"draft": false,
"state": "open"
},
"existed": true
}
type SearchOutput ¶
type SearchOutput struct {
Success bool `json:"success"`
Domain string `json:"domain"`
Query string `json:"query"`
Results []SearchResultInfo `json:"results"`
Error string `json:"error,omitempty"`
}
SearchOutput represents the JSON output of the search command.
type SearchResultInfo ¶
type SearchResultInfo struct {
Resolved string `json:"resolved"`
Label string `json:"label"`
Detail string `json:"detail,omitempty"`
Kind string `json:"kind,omitempty"`
}
SearchResultInfo contains one resolved review metadata search result.
type StartBranchInfo ¶
StartBranchInfo contains branch information for the start command output.
type StartOutput ¶
type StartOutput struct {
Success bool `json:"success"`
Issue *IssueInfo `json:"issue,omitempty"`
Branch *StartBranchInfo `json:"branch,omitempty"`
Error string `json:"error,omitempty"`
}
StartOutput represents the JSON output of the start command.
Example success output:
{
"success": true,
"issue": {
"key": "PROJ-123",
"summary": "Fix login bug",
"status": "In Progress",
"type": "Bug",
"url": "https://jira.example.com/browse/PROJ-123"
},
"branch": {
"name": "feature/PROJ-123-fix-login-bug",
"created": true
}
}
Example error output:
{
"success": false,
"error": "failed to initialize Jira client: authentication required"
}
Source Files
¶
- ai.go
- build_info.go
- cache.go
- command_model.go
- completion.go
- completion_dynamic.go
- completion_mode.go
- config.go
- config_keys.go
- doc.go
- inspect.go
- login.go
- messages.go
- open.go
- output.go
- preflight.go
- release.go
- review.go
- review_executor.go
- root.go
- search.go
- start.go
- start_executor.go
- start_issue.go
- start_output.go
- start_runtime.go
- startup_announcements.go
- telemetry_runtime.go
- testable.go
- version.go