cli

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTimeAgo

func FormatTimeAgo(t time.Time) string

FormatTimeAgo returns a human-readable time difference

Types

type BoostResponse added in v1.7.0

type BoostResponse struct {
	PostID  string `json:"post_id"`
	Boosted bool   `json:"boosted"`
	Message string `json:"message"`
}

BoostResponse represents a boost/unboost response

type ClearNotificationsResponse added in v1.6.2

type ClearNotificationsResponse struct {
	Status  string `json:"status"`
	Cleared bool   `json:"cleared"`
}

ClearNotificationsResponse represents the clear-notifications output

type Database

type Database interface {
	CreateNote(userId interface{}, message string) (interface{}, error)
	CreateNoteWithReply(userId interface{}, message string, inReplyToURI string) (interface{}, error)
	ReadNoteIdWithReplyInfo(id interface{}) (error, *domain.Note)
	ReadHomeTimelinePosts(accountId interface{}, limit int) (error, *[]domain.HomePost)
	ReadNotificationsByAccountId(accountId interface{}, limit int) (error, *[]domain.Notification)
	CountUnreadNotifications(accountId interface{}) (int, error)
	DeleteAllNotifications(accountId interface{}) error

	// Note/Activity lookups for like/boost
	ReadNoteId(id interface{}) (error, *domain.Note)
	ReadActivityById(id interface{}) (error, *domain.Activity)
	ReadAccByUsername(username string) (error, *domain.Account)

	// Like operations
	HasLike(accountId, noteId interface{}) (bool, error)
	HasLikeByObjectURI(accountId interface{}, objectURI string) (bool, error)
	CreateLike(like *domain.Like) error
	CreateLikeByObjectURI(like *domain.Like, objectURI string) error
	DeleteLikeByAccountAndNote(accountId, noteId interface{}) error
	DeleteLikeByAccountAndObjectURI(accountId interface{}, objectURI string) error
	IncrementLikeCountByNoteId(noteId interface{}) error
	DecrementLikeCountByNoteId(noteId interface{}) error
	IncrementLikeCountByObjectURI(objectURI string) error
	DecrementLikeCountByObjectURI(objectURI string) error
	ReadLikeByAccountAndNote(accountId, noteId interface{}) (error, *domain.Like)
	ReadLikeByAccountAndObjectURI(accountId interface{}, objectURI string) (error, *domain.Like)
	CreateNotification(notification *domain.Notification) error

	// Boost operations
	HasBoost(accountId, noteId interface{}) (bool, error)
	HasBoostByObjectURI(accountId interface{}, objectURI string) (bool, error)
	CreateBoost(boost *domain.Boost) error
	CreateBoostByObjectURI(boost *domain.Boost, objectURI string) error
	DeleteBoostByAccountAndNote(accountId, noteId interface{}) error
	DeleteBoostByAccountAndObjectURI(accountId interface{}, objectURI string) error
	IncrementBoostCountByNoteId(noteId interface{}) error
	DecrementBoostCountByNoteId(noteId interface{}) error
	IncrementBoostCountByObjectURI(objectURI string) error
	DecrementBoostCountByObjectURI(objectURI string) error
	ReadBoostByAccountAndNote(accountId, noteId interface{}) (error, *domain.Boost)
	ReadBoostByAccountAndObjectURI(accountId interface{}, objectURI string) (error, *domain.Boost)

	// Follow operations
	ReadRemoteAccountByActorURI(actorURI string) (error, *domain.RemoteAccount)
	ReadFollowByAccountIds(accountId, targetAccountId interface{}) (error, *domain.Follow)
	CreateLocalFollow(followerAccountId, targetAccountId interface{}) error
	DeleteLocalFollow(followerAccountId, targetAccountId interface{}) error
	IsFollowingLocal(followerAccountId, targetAccountId interface{}) (bool, error)
	DeleteFollowByURI(uri string) error
	ReadAccById(id interface{}) (error, *domain.Account)
}

Database interface for CLI operations

type FollowResponse added in v1.7.0

type FollowResponse struct {
	Username  string `json:"username"`
	Domain    string `json:"domain,omitempty"`
	Following bool   `json:"following"`
	Pending   bool   `json:"pending,omitempty"`
	Message   string `json:"message"`
}

FollowResponse represents a follow/unfollow response

type Handler

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

Handler processes CLI commands

func NewHandler

func NewHandler(s Session, db Database, acc *domain.Account, conf *util.AppConfig) *Handler

NewHandler creates a new CLI handler

func (*Handler) Execute

func (h *Handler) Execute(args []string) error

Execute parses and executes a CLI command

type HelpCommand

type HelpCommand struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Usage       string   `json:"usage"`
	Flags       []string `json:"flags,omitempty"`
}

HelpCommand represents a command in help output

type HelpResponse

type HelpResponse struct {
	Version     string        `json:"version"`
	Commands    []HelpCommand `json:"commands"`
	GlobalFlags []string      `json:"global_flags"`
}

HelpResponse represents the help output

type LikeResponse added in v1.7.0

type LikeResponse struct {
	PostID  string `json:"post_id"`
	Liked   bool   `json:"liked"`
	Message string `json:"message"`
}

LikeResponse represents a like/unlike response

type NotificationItem

type NotificationItem struct {
	ID          string    `json:"id"`
	Type        string    `json:"type"`
	Actor       string    `json:"actor"`
	NotePreview string    `json:"note_preview,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
}

NotificationItem represents a notification in output

type NotificationsResponse

type NotificationsResponse struct {
	Notifications []NotificationItem `json:"notifications"`
	UnreadCount   int                `json:"unread_count"`
}

NotificationsResponse represents the notifications output

type Output

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

Output handles formatting responses in text or JSON format

func NewOutput

func NewOutput(w io.Writer, jsonMode bool) *Output

NewOutput creates a new output handler

func (*Output) Error

func (o *Output) Error(err error)

Error outputs an error message

func (*Output) ErrorWithDetails

func (o *Output) ErrorWithDetails(message string, details string)

ErrorWithDetails outputs an error with additional details

func (*Output) IsJSON

func (o *Output) IsJSON() bool

IsJSON returns true if output is in JSON mode

func (*Output) JSON

func (o *Output) JSON(v interface{})

JSON outputs any value as JSON

func (*Output) Print

func (o *Output) Print(format string, args ...interface{})

Print outputs a line (text mode only)

func (*Output) Println

func (o *Output) Println(text string)

Println outputs a line with newline (text mode only)

func (*Output) Success

func (o *Output) Success(format string, args ...interface{})

Success outputs a success message (text mode only, JSON uses specific methods)

type PostResponse

type PostResponse struct {
	ID        string    `json:"id"`
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
	InReplyTo string    `json:"in_reply_to,omitempty"`
}

PostResponse represents a post creation response

type Session

type Session interface {
	io.Reader
	io.Writer
}

Session interface represents the minimal session requirements for CLI operations

type TimelinePost

type TimelinePost struct {
	ID         string    `json:"id"`
	Author     string    `json:"author"`
	Domain     string    `json:"domain,omitempty"`
	Message    string    `json:"message"`
	CreatedAt  time.Time `json:"created_at"`
	ReplyCount int       `json:"reply_count"`
	LikeCount  int       `json:"like_count"`
	BoostCount int       `json:"boost_count"`
	ObjectURI  string    `json:"object_uri,omitempty"`
	IsLocal    bool      `json:"is_local"`
}

TimelinePost represents a post in timeline output

type TimelineResponse

type TimelineResponse struct {
	Posts []TimelinePost `json:"posts"`
	Count int            `json:"count"`
}

TimelineResponse represents the timeline output

Jump to

Keyboard shortcuts

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