cmd

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command *cli.Command
View Source
var OutputFormats = []string{"auto", "json", "jsonline", "pretty", "raw", "yaml"}
View Source
var PaginationFlags = []cli.Flag{
	&cli.IntFlag{
		Name:  "limit",
		Usage: "Maximum number of results to return",
		Value: 20,
	},
	&cli.IntFlag{
		Name:  "offset",
		Usage: "Number of results to skip",
		Value: 0,
	},
}
View Source
var Version = "dev"

Functions

func BuildQueryString

func BuildQueryString(params map[string]string) string

BuildQueryString constructs a query string from key-value pairs, omitting empty values.

func FormatTimeAgo

func FormatTimeAgo(t time.Time) string

func PaginationQuery

func PaginationQuery(cmd *cli.Command) string

func ShowDetail

func ShowDetail(w io.Writer, data gjson.Result)

ShowDetail renders a JSON object as a grouped text display.

func ShowJSON

func ShowJSON(out *os.File, raw string, format string, transform string) error

ShowJSON displays a JSON string in the requested format.

func ShowResult

func ShowResult(out *os.File, res gjson.Result, format string, transform string) error

ShowResult displays a gjson.Result in the requested format.

Types

type APIError

type APIError struct {
	Method     string
	URL        string
	StatusCode int
	Status     string
	Body       string
}

func (*APIError) Error

func (e *APIError) Error() string

type CLIConfig

type CLIConfig struct {
	DefaultProfile string                   `koanf:"default_profile"`
	Profiles       map[string]ProfileConfig `koanf:"profiles"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cmd *cli.Command) (*Client, error)

func NewClientWithBaseURL

func NewClientWithBaseURL(baseURL, apiKey string) *Client

NewClientWithBaseURL creates a client with explicit base URL (useful for testing).

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string) (gjson.Result, error)

func (*Client) DeleteWithBody

func (c *Client) DeleteWithBody(ctx context.Context, path string, jsonBody []byte) (gjson.Result, error)

DeleteWithBody sends a DELETE with a JSON body.

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body io.Reader) (gjson.Result, error)

func (*Client) DoRaw

func (c *Client) DoRaw(ctx context.Context, method, path string) ([]byte, string, error)

DoRaw is like Do but returns the raw response body bytes (for binary responses like PDFs).

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (gjson.Result, error)

func (*Client) PatchJSON

func (c *Client) PatchJSON(ctx context.Context, path string, jsonBody []byte) (gjson.Result, error)

PatchJSON sends a PATCH with a pre-built JSON body.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, jsonBody string) (gjson.Result, error)

func (*Client) PostJSON

func (c *Client) PostJSON(ctx context.Context, path string, jsonBody []byte) (gjson.Result, error)

PostJSON sends a POST with a pre-built JSON body.

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, jsonBody string) (gjson.Result, error)

func (*Client) PutJSON

func (c *Client) PutJSON(ctx context.Context, path string, jsonBody []byte) (gjson.Result, error)

PutJSON sends a PUT with a pre-built JSON body.

type ProfileConfig

type ProfileConfig struct {
	APIKey string `koanf:"api_key"`
}

type TableWriter

type TableWriter struct {

	// TruncOrder specifies column indices in truncation priority order.
	// The first index is truncated first when the table is too wide.
	// Columns not listed are never truncated.
	TruncOrder []int
	// contains filtered or unexported fields
}

func NewTableWriter

func NewTableWriter(w io.Writer, headers ...string) *TableWriter

func (*TableWriter) AddRow

func (t *TableWriter) AddRow(cells ...string)

func (*TableWriter) Render

func (t *TableWriter) Render()

Jump to

Keyboard shortcuts

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