cmd

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: GPL-3.0 Imports: 27 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.7`
	Usage   string = `` /* 619-byte string literal not displayed */

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

Variables

This section is empty.

Functions

func Die

func Die(err error) int

func Execute

func Execute(output io.Writer) int

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

FIXME: check https://github.com/gosimple/slug

func StoreProgress

func StoreProgress(conf *Config, progress int) 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
	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 (c *Config) GetConfigDir() string

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 added in v0.0.5

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

func Prepare added in v0.0.7

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

func PrepareEpub added in v0.0.7

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

func PrepareText added in v0.0.7

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

type Meta

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

Jump to

Keyboard shortcuts

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