Skip to content

Commit c349d67

Browse files
authored
Merge pull request #12 from aredotna/search
Adds missing search params
2 parents 57c1962 + a4f7df7 commit c349d67

3 files changed

Lines changed: 89 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ arena group followers are-na-team
9696
```bash
9797
arena search "brutalist architecture"
9898
arena search "photography" --type Image
99+
arena search "design" --scope my
100+
arena search "*" --type Attachment --ext pdf
101+
arena search "architecture" --sort created_at_desc
102+
arena search "*" --user-id 12345
103+
arena search "*" --channel-id 789
104+
arena search "art" --after 2024-01-01T00:00:00Z
105+
arena search "*" --sort random --seed 42
99106
```
100107

101108
### Other
@@ -135,7 +142,7 @@ arena ping # API health check
135142
| `upload` | `--channel`, `--title`, `--description` |
136143
| `connect` | `--type`, `--position` |
137144
| `connection move` | `--movement`, `--position` |
138-
| `search` | `--scope`, `--ext`, `--after`, `--seed`, `--user-id`, `--group-id`, `--channel-id` |
145+
| `search` | `--scope`, `--sort`, `--ext`, `--after`, `--seed`, `--user-id`, `--group-id`, `--channel-id` |
139146
| `import` | `--dir`, `--recursive`, `--interactive`, `--batch-size`, `--upload-concurrency`, `--poll-interval` |
140147

141148
## Aliases

src/commands/search.tsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { Box, Text } from "ink";
22
import { client, getData } from "../api/client";
3-
import type { Block, ChannelRef, SearchTypeFilter, User } from "../api/types";
3+
import type {
4+
Block,
5+
ChannelRef,
6+
FileExtension,
7+
SearchScope,
8+
SearchSort,
9+
SearchTypeFilter,
10+
User,
11+
} from "../api/types";
412
import { BlockItem } from "../components/BlockItem";
513
import { Spinner } from "../components/Spinner";
614
import { useCommand } from "../hooks/use-command";
@@ -11,9 +19,30 @@ interface Props {
1119
page?: number;
1220
per?: number;
1321
type?: string;
22+
sort?: SearchSort;
23+
scope?: SearchScope;
24+
ext?: FileExtension;
25+
after?: string;
26+
seed?: number;
27+
userId?: number;
28+
groupId?: number;
29+
channelId?: number;
1430
}
1531

16-
export function SearchCommand({ query, page = 1, per = 24, type }: Props) {
32+
export function SearchCommand({
33+
query,
34+
page = 1,
35+
per = 24,
36+
type,
37+
sort,
38+
scope,
39+
ext,
40+
after,
41+
seed,
42+
userId,
43+
groupId,
44+
channelId,
45+
}: Props) {
1746
const { data, error, loading } = useCommand(() =>
1847
getData(
1948
client.GET("/v3/search", {
@@ -23,6 +52,14 @@ export function SearchCommand({ query, page = 1, per = 24, type }: Props) {
2352
page,
2453
per,
2554
type: type ? [type as SearchTypeFilter] : undefined,
55+
sort,
56+
scope,
57+
ext: ext ? [ext] : undefined,
58+
after,
59+
seed,
60+
user_id: userId,
61+
group_id: groupId,
62+
channel_id: channelId,
2663
},
2764
},
2865
}),

src/lib/registry.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,40 @@ export const commands: CommandDefinition[] = [
374374
name: "search",
375375
aliases: ["s"],
376376
group: "Other",
377-
help: [{ usage: "search <query>", description: "Search Are.na" }],
377+
help: [
378+
{ usage: "search <query>", description: "Search Are.na" },
379+
{
380+
usage: "search <query> --type Image",
381+
description:
382+
"Filter by type (Text, Image, Link, Attachment, Embed, Channel, Block, User, Group)",
383+
},
384+
{
385+
usage: "search <query> --scope my",
386+
description: "Limit scope (all, my, following)",
387+
},
388+
{
389+
usage: "search <query> --sort created_at_desc",
390+
description:
391+
"Sort order (score_desc, created_at_desc, created_at_asc, updated_at_desc, updated_at_asc, name_asc, name_desc, connections_count_desc, random)",
392+
},
393+
{
394+
usage: "search <query> --ext pdf",
395+
description: "Filter by file extension",
396+
},
397+
{
398+
usage: "search <query> --after 2024-01-01T00:00:00Z",
399+
description: "Only results updated after timestamp (ISO 8601)",
400+
},
401+
{
402+
usage: "search <query> --channel-id 789",
403+
description:
404+
"Limit to a channel (--user-id, --group-id also available)",
405+
},
406+
{
407+
usage: "search <query> --sort random --seed 42",
408+
description: "Reproducible random ordering",
409+
},
410+
],
378411
session: { args: "<query>", desc: "Search Are.na" },
379412
render(args, flags) {
380413
const query = requireArg([args.join(" ")], 0, "query");
@@ -384,6 +417,14 @@ export const commands: CommandDefinition[] = [
384417
page={optPage(flags)}
385418
per={optPer(flags)}
386419
type={flag(flags, "type")}
420+
sort={flagAs<SearchSort>(flags, "sort")}
421+
scope={flagAs<SearchScope>(flags, "scope")}
422+
ext={flagAs<FileExtension>(flags, "ext")}
423+
after={flag(flags, "after")}
424+
seed={intFlag(flags, "seed")}
425+
userId={intFlag(flags, "user-id")}
426+
groupId={intFlag(flags, "group-id")}
427+
channelId={intFlag(flags, "channel-id")}
387428
/>
388429
);
389430
},

0 commit comments

Comments
 (0)