remotejson

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 12 Imported by: 0

README

RemoteJSON Input Plugin

Type: Input Plugin
Built-in: Yes
Language: Go

Fetch colour palettes from remote JSON APIs with optional JSONPath queries.

Overview

The remotejson plugin fetches colour palettes from HTTP(S) JSON endpoints. It supports JSONPath queries for extracting colours from complex JSON structures and can map source colour names to Tinct's semantic roles.

Features

  • ✅ Fetch from any HTTP(S) JSON endpoint
  • ✅ JSONPath queries for complex JSON structures
  • ✅ Colour format auto-detection (hex, rgb, hsl)
  • ✅ Role mapping (map source names to Tinct roles)
  • ✅ Configurable timeout
  • ✅ Perfect for theme repositories (Catppuccin, Dracula, etc.)

Usage

Basic Fetch
tinct generate -i remote-json \
  --remote-json.url "https://example.com/palette.json" \
  -o hyprland,kitty
With JSONPath Query
tinct generate -i remote-json \
  --remote-json.url "https://api.example.com/themes/dark.json" \
  --remote-json.query "$.colours" \
  -o hyprland
With Role Mapping
tinct generate -i remote-json \
  --remote-json.url "https://example.com/theme.json" \
  --remote-json.map "base=background,text=foreground,blue=accent1" \
  -o hyprland

CLI Flags

Flag Default Description
--remote-json.url (required) JSON URL to fetch
--remote-json.query (optional) JSONPath query (e.g., $.colours)
--remote-json.timeout 10s HTTP request timeout
--remote-json.map {} Map source names to roles

Supported Colour Formats

The plugin auto-detects and parses:

  • Hex: #RRGGBB, RRGGBB, #RGB
  • RGB: rgb(R, G, B), {"r": R, "g": G, "b": B}
  • HSL: hsl(H, S%, L%)

Examples

Catppuccin Mocha
tinct generate -i remote-json \
  --remote-json.url "https://raw.githubusercontent.com/catppuccin/palette/main/palette.json" \
  --remote-json.query "$.mocha.colours" \
  -o hyprland,kitty
Custom API
tinct generate -i remote-json \
  --remote-json.url "https://myapi.com/theme/dark" \
  --remote-json.map "bg=background,fg=foreground,primary=accent1" \
  -o hyprland

License

MIT License - Same as Tinct

Documentation

Overview

Package remotejson provides an input plugin for fetching colour palettes from remote JSON sources with JSONPath queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

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

Plugin implements the input.Plugin interface for remote JSON palette fetching with JSONPath queries.

func New

func New() *Plugin

New creates a new remote-json input plugin.

func (*Plugin) Description

func (p *Plugin) Description() string

Description returns the plugin description.

func (*Plugin) Generate

func (p *Plugin) Generate(ctx context.Context, opts input.GenerateOptions) (*colour.Palette, error)

Generate fetches and parses a remote JSON colour palette.

func (*Plugin) GetFlagHelp

func (p *Plugin) GetFlagHelp() []input.FlagHelp

GetFlagHelp returns help information for all plugin flags.

func (*Plugin) Name

func (p *Plugin) Name() string

Name returns the plugin name.

func (*Plugin) RegisterFlags

func (p *Plugin) RegisterFlags(cmd *cobra.Command)

RegisterFlags registers plugin-specific flags with the cobra command.

func (*Plugin) Validate

func (p *Plugin) Validate() error

Validate checks if the plugin has all required inputs configured.

func (*Plugin) Version

func (p *Plugin) Version() string

Version returns the plugin version.

Jump to

Keyboard shortcuts

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