parse

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package parse turns slio's raw CLI arguments (thread URLs, channel references, --since/--until values) into structured data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Time added in v1.0.4

func Time(raw string, now time.Time) (time.Time, error)

Time parses a --since/--until value relative to now: ISO 8601 (with or without a time-of-day component; no zone means now's location) or a relative duration meaning "that long before now" (30m, 24h, 7d, 2w). Go's time.ParseDuration doesn't support d/w, so only those two units are hand-rolled; everything else is delegated to it.

Types

type Channel

type Channel struct {
	Host string
	ID   string
	Name string
}

Channel is a parsed history/thread channel argument: a URL or bare channel/DM/group-DM ID (ID set, Host set only for the URL form), or a "#name" reference (Name set, left for the caller to resolve via the channel cache).

func ChannelArg added in v1.0.4

func ChannelArg(raw string) (Channel, error)

ChannelArg parses the argument to `slio history`: a Slack URL, a bare channel/DM/group-DM ID, or a "#name" reference.

type ThreadRef

type ThreadRef struct {
	Host    string
	Channel string
	// Ts is the thread to fetch: the parent message's timestamp.
	Ts string
	// TargetTs is the timestamp of the message the URL pointed at, taken
	// from the permalink's p<digits> segment. It equals Ts for a parent
	// permalink and differs for a reply permalink.
	TargetTs string
}

ThreadRef identifies a single Slack thread: the channel it lives in, its workspace host, the timestamp to fetch the thread from, and the timestamp of the one message the URL pointed at.

func ThreadURL

func ThreadURL(raw string) (ThreadRef, error)

ThreadURL parses a Slack message permalink into a ThreadRef. It accepts both the canonical form (.../archives/<channel>/p<digits>) and a reply permalink carrying ?thread_ts=<ts>&cid=<channel>. The two carry different information and both parts are kept: thread_ts (when present) is the thread to fetch, while the p<digits> segment always names the message the URL pointed at. Passing a reply's ts to conversations.replies would return that reply alone rather than the thread it belongs to — which is also why a reply permalink stripped of its ?thread_ts= (not a form Slack's "Copy link" produces) resolves to that reply alone, leaving it the only message `slio thread` has to mark.

Jump to

Keyboard shortcuts

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