cli

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cli builds the ytb command tree on top of the youtube library.

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)

Build metadata, set via -ldflags at release time.

Functions

func Execute

func Execute(ctx context.Context, cmd *cobra.Command) int

Execute runs the root command, mapping errors to exit codes.

func ExitCode

func ExitCode(err error) int

ExitCode maps an error to a process exit code per the documented table.

func Root

func Root() *cobra.Command

Root builds the root command and its whole subtree.

Types

type App

type App struct {
	Cfg    youtube.Config
	Client *youtube.Client
	Out    *Output
	DBPath string

	Limit    int
	MaxPages int
	Workers  int

	YtDlpBin  string
	FFmpegBin string
	// contains filtered or unexported fields
}

App carries the resolved configuration and shared clients for a command run.

func (*App) PageOptions

func (a *App) PageOptions(enrich bool) youtube.PageOptions

PageOptions builds a PageOptions from the global -n / --max-pages flags.

func (*App) RequireStore

func (a *App) RequireStore() (*youtube.Store, error)

RequireStore returns the store or a usage error if --db is unset.

func (*App) Store

func (a *App) Store() (*youtube.Store, error)

Store opens (once) and returns the optional SQLite store, or nil if --db is unset.

type Format

type Format string

Format is an output encoding.

const (
	FormatAuto  Format = "auto"
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatJSONL Format = "jsonl"
	FormatCSV   Format = "csv"
	FormatTSV   Format = "tsv"
	FormatURL   Format = "url"
	FormatID    Format = "id"
	FormatRaw   Format = "raw"
)

type Output

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

Output renders rows in the selected format. A single Output instance handles a whole command run, so streaming formats can write incrementally.

func (*Output) Emit

func (o *Output) Emit(r Row) error

Emit renders one row.

func (*Output) Flush

func (o *Output) Flush() error

Flush finalises buffered formats. Call once at the end of a command.

func (*Output) Format

func (o *Output) Format() Format

Format returns the resolved output format.

func (*Output) Line

func (o *Output) Line(s string) error

Line writes a single plain line to stdout (for suggest/transcript text).

func (*Output) Raw

func (o *Output) Raw(b []byte) error

Raw writes bytes straight to stdout (for --raw content).

type Row

type Row struct {
	Cols  []string
	Vals  []string
	Value any
}

Row is one output record: an ordered set of named columns plus the original value (used by json/jsonl and templates).

Jump to

Keyboard shortcuts

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