youngutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package youngutil contains the small amount of transport and date handling shared by Young catalog and workspace commands.

Index

Constants

View Source
const (
	EventsPath                      = "/api/catalog/young-events"
	OrganizersPath                  = "/api/catalog/young-organizers"
	YoungEventSubscriptionsPath     = "/api/workspace/young-event-subscriptions"
	YoungOrganizerSubscriptionsPath = "/api/workspace/young-organizer-subscriptions"
	YoungNotificationsPath          = "/api/workspace/young-notifications"
	PersonalCalendarEventsPath      = "/api/workspace/calendar/events"
)

Variables

View Source
var Shanghai = time.FixedZone("Asia/Shanghai", 8*60*60)

Functions

func DateRange

func DateRange(view DateView, anchor string, now time.Time) (string, string, error)

DateRange returns inclusive Shanghai calendar-date bounds for an anchor. An empty anchor means today in Asia/Shanghai.

func FetchAllIfUnpaged

func FetchAllIfUnpaged(
	ctx context.Context,
	fetch func(context.Context, url.Values) (any, error),
	path string,
	params url.Values,
	key string,
	pageSize int,
	identityKey string,
) (any, error)

FetchAllIfUnpaged follows every page when the caller did not explicitly select a page or page size. Explicit pagination remains server-side so the command can be used for bounded scripts as well as complete interactive listings.

func FetchAllPages

func FetchAllPages(
	ctx context.Context,
	fetch func(context.Context, url.Values) (any, error),
	path string,
	params url.Values,
	key string,
	pageSize int,
	identityKey string,
) (any, error)

FetchAllPages reads every page of a standard {data, pagination} response. The returned response is rewritten as one complete page so table, JSON and jq output all describe the same result.

func PageParams

func PageParams(page, limit int) (url.Values, error)

PageParams validates CLI pagination flags and maps --limit to pageSize.

func PathID

func PathID(base, id string) string

PathID appends an opaque public identifier to a REST path safely.

func RequireID

func RequireID(value, flag string) (string, error)

RequireID trims a positional or path identifier and rejects an empty value. Cobra's argument count checks do not catch whitespace-only IDs.

Types

type DateView

type DateView string
const (
	DateDay   DateView = "day"
	DateWeek  DateView = "week"
	DateMonth DateView = "month"
)

Jump to

Keyboard shortcuts

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