flags

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package flags defines shared CLI flags and argument parsers.

Index

Constants

View Source
const (
	ConfigFlag      = "config"
	LoginFlag       = "login"
	BaseURLFlag     = "base-url"
	OutputFlag      = "output"
	JSONFlag        = "json"
	JSONCompactFlag = "json-compact"
	JQFlag          = "jq"
	JSONErrorsFlag  = "json-errors"
	QuietFlag       = "quiet"
	DryRunFlag      = "dry-run"
	RepoFlag        = "repo"
	OwnerFlag       = "owner"
)
View Source
const (
	OutputTable       = "table"
	OutputJSON        = "json"
	OutputJSONCompact = "json-compact"
)
View Source
const (
	PageFlag     = "page"
	PerPageFlag  = "per-page"
	LimitFlag    = "limit"
	PageInfoFlag = "page-info"
	StateFlag    = "state"
	QueryFlag    = "query"
	YesFlag      = "yes"
	FileFlag     = "file"
	OutputFile   = "output-file"
)

Variables

This section is empty.

Functions

func Confirm

func Confirm(in io.Reader, out io.Writer, prompt string, assumeYes bool) (bool, error)

Confirm asks the user to confirm unless assumeYes is true.

func DryRun

func DryRun() cli.Flag

DryRun returns the command-local dry-run flag for supported mutating commands.

func FilterFlags

func FilterFlags() []cli.Flag

FilterFlags returns common list filter flags.

func Global

func Global() []cli.Flag

Global returns flags available to all commands.

func OpenDownloadDestination

func OpenDownloadDestination(path string, stdout io.Writer) (io.WriteCloser, error)

OpenDownloadDestination opens a file for writing. A path of "-" writes to stdout.

func OpenInput

func OpenInput(path string, stdin io.Reader) (io.ReadCloser, error)

OpenInput opens a file for reading. A path of "-" reads from stdin.

func OutputFormat

func OutputFormat(cmd *cli.Command) (string, error)

OutputFormat resolves the effective machine output format.

func PaginationFlags

func PaginationFlags() []cli.Flag

PaginationFlags returns common pagination flags.

func ValidateOutputFlags

func ValidateOutputFlags(cmd *cli.Command) error

ValidateOutputFlags returns an error for conflicting global output flags.

func WantsJSONOutput

func WantsJSONOutput(cmd *cli.Command) bool

WantsJSONOutput reports whether stdout is expected to be JSON.

Types

type GitRepositoryResolver

type GitRepositoryResolver func() (RepoRef, error)

GitRepositoryResolver resolves the current Git repository from the local working tree.

type Pagination

type Pagination struct {
	Page     int
	PerPage  int
	Limit    int
	PageInfo bool
}

Pagination contains shared pagination values.

func PaginationFromCommand

func PaginationFromCommand(cmd *cli.Command) Pagination

PaginationFromCommand reads shared pagination flags.

type RepoRef

type RepoRef struct {
	Owner string
	Name  string
}

RepoRef identifies a GitVerse repository.

func DetectCurrentGitRepository

func DetectCurrentGitRepository() (RepoRef, error)

DetectCurrentGitRepository resolves the repository from git remote origin.

func ParseRepo

func ParseRepo(repoArg, owner, repoName string) (RepoRef, error)

ParseRepo parses either owner/repo or separate owner and repository names.

func (RepoRef) String

func (r RepoRef) String() string

String returns owner/name.

type RepoSelection

type RepoSelection struct {
	RepoRef
	ArgOffset int
}

RepoSelection is a resolved repository and the number of positional arguments consumed by a legacy repository argument.

func ResolveExplicitRepo

func ResolveExplicitRepo(cmd *cli.Command) (RepoSelection, error)

ResolveExplicitRepo resolves a repository for commands where the first positional argument, when present, is explicitly a repository argument.

func ResolveExplicitRepoWith

func ResolveExplicitRepoWith(cmd *cli.Command, current GitRepositoryResolver) (RepoSelection, error)

ResolveExplicitRepoWith resolves an explicit repository argument using a custom current Git repository resolver.

func ResolveRepo

func ResolveRepo(cmd *cli.Command) (RepoSelection, error)

ResolveRepo resolves GH-style repository selection for repo-scoped commands without consuming positional arguments. Commands that accept owner/repo as a positional argument must use ResolveExplicitRepo.

func ResolveRepoContext

func ResolveRepoContext(cmd *cli.Command) (RepoSelection, error)

ResolveRepoContext resolves repository selection without consuming positional arguments. It is intended for commands whose first argument is not a repository but may still need repo placeholders.

func ResolveRepoContextWith

func ResolveRepoContextWith(cmd *cli.Command, current GitRepositoryResolver) (RepoSelection, error)

ResolveRepoContextWith resolves repository selection without consuming positional arguments using a custom current Git repository resolver.

func ResolveRepoWith

func ResolveRepoWith(cmd *cli.Command, current GitRepositoryResolver) (RepoSelection, error)

ResolveRepoWith resolves repository selection using a custom current Git repository resolver.

Source Files

  • confirm.go
  • doc.go
  • global.go
  • io.go
  • output.go
  • pagination.go
  • repo.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL