Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Built on [Charm](https://charm.sh/)'s excellent BubbleTea, Huh, and Lipgloss lib

## Development

Business logic lives in `internal/book` as pure, testable functions: URL validation, tag parsing, title resolution, ID generation, and shelf/collection/mark helpers. The `cmd` and `internal/model` packages are thin adapters over this layer.
Business logic lives in `pkg/book` as pure, testable functions: URL validation, tag parsing, title resolution, ID generation, and shelf/collection/mark helpers. The `cmd` and `internal/model` packages are thin adapters over this layer.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions cmd/book/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"
"testing"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

func testConfig(t *testing.T) *theme.UIConfig {
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

"github.com/BurntSushi/toml"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

// dumpDefaults serialises the built-in theme or template defaults as indented JSON.
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package cmd
import (
"fmt"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/model"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

func collections(cache *indexCache, bs *book.BookShelves, shelfName string, format string, config *theme.UIConfig) error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"fmt"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

// doctor inspects the catalog for post-merge problems: duplicate marks, schema
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"time"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

// gc purges soft-deleted marks older than retentionDays from the shelf TOML
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"fmt"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

// indexCache holds the lazily-opened SQLite index shared by the read paths
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
validation "github.com/urfave/cli-validation"
"github.com/urfave/cli/v3"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/model"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions cmd/book/mark.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"errors"
"fmt"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/model"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/internal/web"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
"github.com/polymorcodeus/book/pkg/web"
)

func getMark(bs *book.BookShelves, id, url, format string, config *theme.UIConfig) error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package cmd
import (
"fmt"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

func migrate(config *book.Config) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/book/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"fmt"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// printCatalog marshals an item in the given format and prints it.
Expand Down
4 changes: 2 additions & 2 deletions cmd/book/shelf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"os"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/model"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

func shelves(cache *indexCache, bs *book.BookShelves, format string, config *theme.UIConfig) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/book/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"charm.land/huh/v2/spinner"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/web"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
"github.com/polymorcodeus/book/pkg/web"
)

// loadCatalog loads shelves with an optional spinner when running interactively.
Expand Down
4 changes: 2 additions & 2 deletions internal/model/collection_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"charm.land/huh/v2"
"charm.land/lipgloss/v2"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

type collectionModel struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/model/mark_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"charm.land/huh/v2"
"charm.land/lipgloss/v2"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/internal/web"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
"github.com/polymorcodeus/book/pkg/web"
)

type markModel struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/model/shelf_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
tea "charm.land/bubbletea/v2"
"charm.land/huh/v2"
"charm.land/lipgloss/v2"
"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/catalog"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
"github.com/polymorcodeus/book/pkg/catalog"
)

type shelfModel struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/model/tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
tea "charm.land/bubbletea/v2"
"charm.land/huh/v2"
"charm.land/lipgloss/v2"
"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/internal/theme"
"github.com/polymorcodeus/book/pkg/book"
)

const maxWidth = 120
Expand Down
2 changes: 1 addition & 1 deletion internal/theme/uiconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"maps"
"os"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

const errorBullet string = "󰯷" // "nf-md-alpha_e_box_outline
Expand Down
2 changes: 1 addition & 1 deletion internal/theme/uiconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"testing"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

func TestUIConfigStyledError(t *testing.T) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/catalog/catalog.go → pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/BurntSushi/toml"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// LoadShelves reads all shelf TOML files from disk into the given BookShelves.
Expand Down
2 changes: 1 addition & 1 deletion internal/catalog/doctor.go → pkg/catalog/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"

"github.com/BurntSushi/toml"
"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// V1ShelfFiles returns the shelf TOML files in dir that still use the v1 schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"slices"
"testing"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

const v1Fixture = `shelf_name = "work"
Expand Down
2 changes: 1 addition & 1 deletion internal/catalog/index.go → pkg/catalog/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/BurntSushi/toml"
_ "modernc.org/sqlite" // registers the pure-Go "sqlite" driver

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// indexSchema creates the derived SQLite index. TOML remains the source of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"testing"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

func testConfig(t *testing.T) *book.Config {
Expand Down
2 changes: 1 addition & 1 deletion internal/catalog/migrate.go → pkg/catalog/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/BurntSushi/toml"
"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// MigrateReport summarizes the result of a MigrateShelfDir run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/BurntSushi/toml"
"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// fixtureMigratedTOML is the expected v2 output after migrating fixtureTOML.
Expand Down
2 changes: 1 addition & 1 deletion internal/catalog/toml.go → pkg/catalog/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/BurntSushi/toml"

"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// VerifyExists reports whether a file or directory exists at the given path.
Expand Down
2 changes: 1 addition & 1 deletion internal/catalog/toml_test.go → pkg/catalog/toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"

"github.com/BurntSushi/toml"
"github.com/polymorcodeus/book/internal/book"
"github.com/polymorcodeus/book/pkg/book"
)

// fixtureTOML matches the real archive.toml format: nested map tables for
Expand Down
File renamed without changes.
File renamed without changes.
Loading