Help us shape the future of Go! Take the 2026 Go Developer Survey

lib

package
v0.4.1-dev.26.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UpdateStageDownload = "download"
	UpdateStageExtract  = "extract"
	UpdateStagePrepare  = "prepare"
	UpdateStageReplace  = "replace"
)

Variables

View Source
var (
	Logo = `
ReadCLI V%s
https://github.com/lvshp/ReadCLI
`
)

Functions

func CurrentExecutablePath

func CurrentExecutablePath() string

func CurrentPlatformSupported

func CurrentPlatformSupported() bool

func DataDirPath

func DataDirPath() (string, error)

func DisplayVersion

func DisplayVersion(version string)

func InstallLatestReleaseAsset

func InstallLatestReleaseAsset(version, url, executablePath string) error

func InstallLatestReleaseAssetWithProgress added in v0.3.5

func InstallLatestReleaseAssetWithProgress(version, url, executablePath string, onProgress UpdateProgressFunc) error

On Windows, nil means the update helper has prepared the new executable and will install it after this process exits. Other platforms install immediately.

func NormalizeConfiguredColor

func NormalizeConfiguredColor(value string) string

func ParseRowNum

func ParseRowNum(rowNum string) (int, error)

func RemoveBookshelfBook

func RemoveBookshelfBook(store *BookshelfStore, path string)

func RunUpdateHelper added in v0.3.7

func RunUpdateHelper(args []string) (bool, int)

func SaveBookmarks

func SaveBookmarks(store *BookmarkStore) error

func SaveBookshelf

func SaveBookshelf(store *BookshelfStore) error

func SaveConfig

func SaveConfig(cfg *Config) error

func SaveProgress

func SaveProgress(store *ProgressStore) error

func ShouldOfferUpdate

func ShouldOfferUpdate(currentVersion, latestVersion string) bool

func SortBooks

func SortBooks(books []BookshelfBook, order string)

func UpsertBookshelfBook

func UpsertBookshelfBook(store *BookshelfStore, book BookshelfBook)

Types

type Bookmark

type Bookmark struct {
	ChapterURL    string  `json:"chapter_url,omitempty"`
	ChapterOffset float64 `json:"chapter_offset,omitempty"`
	Path          string  `json:"path"`
	Position      int     `json:"position"`
	Chapter       string  `json:"chapter"`
	Snippet       string  `json:"snippet"`
	CreatedAt     string  `json:"created_at"`
	ProgressTotal int     `json:"progress_total"`
}

type BookmarkStore

type BookmarkStore struct {
	Books map[string][]Bookmark `json:"books"`
}

func LoadBookmarks

func LoadBookmarks() (*BookmarkStore, error)

type BookshelfBook

type BookshelfBook struct {
	Online          *booksource.Book `json:"online,omitempty"`
	ChapterURL      string           `json:"chapter_url,omitempty"`
	Path            string           `json:"path"`
	Title           string           `json:"title"`
	Format          string           `json:"format"`
	ProgressPos     int              `json:"progress_pos"`
	ProgressTotal   int              `json:"progress_total"`
	ProgressPercent int              `json:"progress_percent"`
	CurrentChapter  string           `json:"current_chapter"`
	ChapterIndex    int              `json:"chapter_index"`
	ChapterOffset   float64          `json:"chapter_offset"`
	LastReadAt      string           `json:"last_read_at"`
	ImportedAt      string           `json:"imported_at"`
}

func FilterBooks

func FilterBooks(books []BookshelfBook, filter string) []BookshelfBook

func FindBookshelfBook

func FindBookshelfBook(store *BookshelfStore, path string) (BookshelfBook, bool)

type BookshelfStore

type BookshelfStore struct {
	Books []BookshelfBook `json:"books"`
}

func LoadBookshelf

func LoadBookshelf() (*BookshelfStore, error)

type Config

type Config struct {
	Theme                    string  `json:"theme"`
	DisplayLines             int     `json:"display_lines"`
	ShowBorder               bool    `json:"show_border"`
	CompactMode              bool    `json:"compact_mode"`
	SelectedBookshelf        int     `json:"selected_bookshelf"`
	SkippedUpdateVersion     string  `json:"skipped_update_version"`
	BossKeyCommand           string  `json:"boss_key_command"`
	ForceBasicColor          bool    `json:"force_basic_color"`
	AutoPageIntervalMs       int     `json:"auto_page_interval_ms"`
	ReadingContentWidthRatio float64 `json:"reading_content_width_ratio"`
	ReadingAlignment         string  `json:"reading_alignment,omitempty"`
	ReadingMarginLeft        int     `json:"reading_margin_left"`
	ReadingMarginRight       int     `json:"reading_margin_right"`
	ReadingMarginTop         int     `json:"reading_margin_top"`
	ReadingMarginBottom      int     `json:"reading_margin_bottom"`
	ReadingLineSpacing       int     `json:"reading_line_spacing"`
	ReadingTextColor         string  `json:"reading_text_color"`
	ReadingHighContrast      bool    `json:"reading_high_contrast"`
}

func LoadConfig

func LoadConfig() (*Config, error)

type ProgressAnchor

type ProgressAnchor struct {
	Pos           int     `json:"pos"`
	ChapterIndex  int     `json:"chapter_index"`
	ChapterOffset float64 `json:"chapter_offset"`
	OverallRatio  float64 `json:"overall_ratio"`
}

type ProgressStore

type ProgressStore struct {
	Books   map[string]int            `json:"books"`
	Anchors map[string]ProgressAnchor `json:"anchors,omitempty"`
}

func LoadProgress

func LoadProgress() (*ProgressStore, error)

type ReleaseAsset

type ReleaseAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

func SelectReleaseAsset

func SelectReleaseAsset(release *ReleaseInfo, goos, goarch string) *ReleaseAsset

type ReleaseInfo

type ReleaseInfo struct {
	TagName string         `json:"tag_name"`
	Name    string         `json:"name"`
	Body    string         `json:"body"`
	Assets  []ReleaseAsset `json:"assets"`
}

func FetchLatestRelease

func FetchLatestRelease(version string) (*ReleaseInfo, error)

type UpdateInstallError

type UpdateInstallError struct {
	Message string
	TempDir string
}

func (*UpdateInstallError) Error

func (e *UpdateInstallError) Error() string

type UpdateProgress added in v0.3.5

type UpdateProgress struct {
	Stage      string
	Downloaded int64
	Total      int64
}

type UpdateProgressFunc added in v0.3.5

type UpdateProgressFunc func(UpdateProgress)

Jump to

Keyboard shortcuts

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