cmd

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Copyright © 2025 Thomas von Dein

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	Version string = `v0.0.8`
	Usage   string = `` /* 673-byte string literal not displayed */

)
View Source
const (
	MarginStep = 5
	MinSize    = 40
)

Variables

View Source
var (
	DefaultDark = ColorSetting{
		Title:   "#ff4500",
		Chapter: "#ff4500",
		Body:    "#cdb79e",
	}

	DefaultLight = ColorSetting{
		Title:   "#ff0000",
		Chapter: "#8b0000",
		Body:    "#696969",
	}
)

Functions

func Die

func Die(err error) int

func Execute

func Execute(output io.Writer) int

func FileExists

func FileExists(filename string) bool

func GetProgress

func GetProgress(conf *Config) (int64, error)

func Mkdir

func Mkdir(dir string) error

func Pager

func Pager(book *Ebook) (int, error)

func Slug

func Slug(input string) string

func StoreProgress

func StoreProgress(conf *Config, progress int) error

func WriteFile

func WriteFile(filename string, content []byte) error

Types

type ColorSetting

type ColorSetting struct {
	Title   string `koanf:"title"`
	Chapter string `koanf:"chapter"`
	Body    string `koanf:"body"`
}

type Colors

type Colors struct {
	Title   lipgloss.Style
	Chapter lipgloss.Style
	Body    lipgloss.Style
}

func SetColorconfig

func SetColorconfig(defaultdark, defaultlight ColorSetting, conf *Config) Colors

type Config

type Config struct {
	Showversion     bool         `koanf:"version"`        // -v
	Debug           bool         `koanf:"debug"`          // -d
	StoreProgress   bool         `koanf:"store-progress"` // -s
	Darkmode        bool         `koanf:"dark"`           // -D
	LineNumbers     bool         `koanf:"line-numbers"`   // -n
	Dump            bool         `koanf:"txt"`            // -t
	XML             bool         `koanf:"xml"`            // -x
	NoColor         bool         `koanf:"no-color"`       // -n
	Config          string       `koanf:"config"`         // -c
	ColorDark       ColorSetting `koanf:"colordark"`      // comes from config file only
	ColorLight      ColorSetting `koanf:"colorlight"`     // comes from config file only
	ShowHelp        bool         `koanf:"help"`
	ShowCover       bool         `koanf:"cover-image"`   // -i
	CreateConfig    bool         `koanf:"create-config"` // --create-config
	Colors          Colors       // generated from user config file or internal defaults, respects dark mode
	Document        string
	InitialProgress int // lines
}

func InitConfig

func InitConfig(output io.Writer) (*Config, error)

func (*Config) GetConfigDir

func (conf *Config) GetConfigDir() string

func (*Config) WriteConfigFile

func (conf *Config) WriteConfigFile() (string, error)

type Doc

type Doc struct {
	Cover *termimg.ImageWidget
	// contains filtered or unexported fields
}

func (Doc) Init

func (m Doc) Init() tea.Cmd

func (*Doc) Rewrap

func (m *Doc) Rewrap()

re-calculate word wrapping, add left margin, recalculate line count

func (Doc) Update

func (m Doc) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Doc) View

func (m Doc) View() string

type Ebook

type Ebook struct {
	Config    *Config
	Title     string
	Body      string
	Cover     []byte
	MediaType string
}

func Prepare

func Prepare(conf *Config) (*Ebook, error)

func PrepareEpub

func PrepareEpub(conf *Config) (*Ebook, error)

func PrepareText

func PrepareText(conf *Config) (*Ebook, error)

type Meta

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

type UserConfig

type UserConfig struct {
	StoreProgress bool         `koanf:"store-progress"`
	Darkmode      bool         `koanf:"dark"`
	LineNumbers   bool         `koanf:"line-numbers"`
	NoColor       bool         `koanf:"no-color"`
	ColorDark     ColorSetting `koanf:"colordark"`
	ColorLight    ColorSetting `koanf:"colorlight"`
}

used for config writing, it's a subset of the Config struct add fields as you add user configurable fields to Config

Jump to

Keyboard shortcuts

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