cli

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDirectories

func EnsureDirectories() error

EnsureDirectories creates all necessary directories

func Execute

func Execute() error

Execute runs the root command

func GetAliasesPath

func GetAliasesPath() string

GetAliasesPath returns the path to the aliases file

func GetConfigDir

func GetConfigDir() string

GetConfigDir returns the config directory path Uses XDG_CONFIG_HOME if set, otherwise ~/.config/whatsapp-cli

func GetFields

func GetFields() []string

GetFields returns the list of fields to include in output

func GetMediaDir

func GetMediaDir() string

GetMediaDir returns the directory for downloaded media

func GetMessagesDBPath

func GetMessagesDBPath() string

GetMessagesDBPath returns the path to the messages database

func GetSessionDBPath

func GetSessionDBPath() string

GetSessionDBPath returns the path to the whatsmeow session database

func GetStoreDir

func GetStoreDir() string

GetStoreDir returns the store directory for databases

func IsJSON

func IsJSON() bool

IsJSON returns whether JSON output is enabled (json or jsonl)

func IsVerbose

func IsVerbose() bool

IsVerbose returns whether verbose mode is enabled

func NoAutoSync added in v0.2.0

func NoAutoSync() bool

NoAutoSync returns whether auto-sync is disabled

func NoHeader

func NoHeader() bool

NoHeader returns whether to skip header row in CSV/TSV output

func Output

func Output(data any) error

Output helper for commands - returns error for proper handling

func OutputResult

func OutputResult(data any, humanMsg string) error

OutputResult outputs structured data for machine formats, or a human message for human format

func OutputWarning

func OutputWarning(format string, args ...any)

OutputWarning prints warning to stderr (for non-fatal issues)

func ParseTimeframe

func ParseTimeframe(timeframe string) (after string, before string, err error)

ParseTimeframe converts a timeframe preset string into after/before timestamps.

func RemoveAlias

func RemoveAlias(jid string) error

RemoveAlias removes an alias for a JID

func SetAlias

func SetAlias(jid, alias string) error

SetAlias sets an alias for a JID

func SetStoreDir

func SetStoreDir(dir string)

SetStoreDir sets a custom store directory

func WithConnection

func WithConnection(fn func(*store.DB, *whatsapp.Client) error) error

WithConnection opens the database, creates a WhatsApp client, verifies authentication, connects to WhatsApp, and runs the provided function. Performs auto-sync if last sync was over 24 hours ago.

func WithDB

func WithDB(fn func(*store.DB) error) error

WithDB opens the database and runs the provided function. Performs auto-sync if last sync was over 24 hours ago.

Types

type Aliases

type Aliases map[string]string // alias -> JID

Aliases manages local JID aliases

func LoadAliases

func LoadAliases() (Aliases, error)

LoadAliases loads aliases from disk

func (Aliases) Get

func (a Aliases) Get(aliasOrJID string) string

Get returns the JID for an alias, or the input if not found

func (Aliases) Remove

func (a Aliases) Remove(alias string)

Remove removes an alias

func (Aliases) Save

func (a Aliases) Save() error

Save saves aliases to disk

func (Aliases) Set

func (a Aliases) Set(alias, jid string)

Set adds or updates an alias

type Format

type Format string

Format represents the output format

const (
	FormatJSON  Format = "json"
	FormatJSONL Format = "jsonl"
	FormatCSV   Format = "csv"
	FormatTSV   Format = "tsv"
	FormatHuman Format = "human"
)

func GetFormat

func GetFormat() Format

GetFormat returns the cached output format

func (Format) IsValid

func (f Format) IsValid() bool

IsValid checks if a format string is valid

type JIDAlias

type JIDAlias map[string]string // JID -> alias

JIDAlias maps JIDs to their aliases (reversed from Aliases)

func ListAliases

func ListAliases() (JIDAlias, error)

ListAliases returns all aliases as JID -> alias map

type OutputOptions

type OutputOptions struct {
	Format   Format
	Fields   []string // Field names to include (empty = all)
	NoHeader bool     // Skip header row for CSV/TSV
}

OutputOptions controls output behavior

func GetOutputOptions

func GetOutputOptions() OutputOptions

GetOutputOptions returns the current output options

func (OutputOptions) Validate

func (o OutputOptions) Validate() error

Validate checks if the options are valid

type TimeframePreset

type TimeframePreset string

TimeframePreset represents a named time range.

const (
	TimeframeLastHour  TimeframePreset = "last_hour"
	TimeframeToday     TimeframePreset = "today"
	TimeframeYesterday TimeframePreset = "yesterday"
	TimeframeLast3Days TimeframePreset = "last_3_days"
	TimeframeThisWeek  TimeframePreset = "this_week"
	TimeframeLastWeek  TimeframePreset = "last_week"
	TimeframeThisMonth TimeframePreset = "this_month"
)

Jump to

Keyboard shortcuts

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