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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ arena group followers are-na-team
```bash
arena search "brutalist architecture"
arena search "photography" --type Image
arena search "design" --scope my
arena search "*" --type Attachment --ext pdf
arena search "architecture" --sort created_at_desc
arena search "*" --user-id 12345
arena search "*" --channel-id 789
arena search "art" --after 2024-01-01T00:00:00Z
arena search "*" --sort random --seed 42
```

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

## Aliases
Expand Down
41 changes: 39 additions & 2 deletions src/commands/search.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Box, Text } from "ink";
import { client, getData } from "../api/client";
import type { Block, ChannelRef, SearchTypeFilter, User } from "../api/types";
import type {
Block,
ChannelRef,
FileExtension,
SearchScope,
SearchSort,
SearchTypeFilter,
User,
} from "../api/types";
import { BlockItem } from "../components/BlockItem";
import { Spinner } from "../components/Spinner";
import { useCommand } from "../hooks/use-command";
Expand All @@ -11,9 +19,30 @@ interface Props {
page?: number;
per?: number;
type?: string;
sort?: SearchSort;
scope?: SearchScope;
ext?: FileExtension;
after?: string;
seed?: number;
userId?: number;
groupId?: number;
channelId?: number;
}

export function SearchCommand({ query, page = 1, per = 24, type }: Props) {
export function SearchCommand({
query,
page = 1,
per = 24,
type,
sort,
scope,
ext,
after,
seed,
userId,
groupId,
channelId,
}: Props) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/search", {
Expand All @@ -23,6 +52,14 @@ export function SearchCommand({ query, page = 1, per = 24, type }: Props) {
page,
per,
type: type ? [type as SearchTypeFilter] : undefined,
sort,
scope,
ext: ext ? [ext] : undefined,
after,
seed,
user_id: userId,
group_id: groupId,
channel_id: channelId,
},
},
}),
Expand Down
43 changes: 42 additions & 1 deletion src/lib/registry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,40 @@ export const commands: CommandDefinition[] = [
name: "search",
aliases: ["s"],
group: "Other",
help: [{ usage: "search <query>", description: "Search Are.na" }],
help: [
{ usage: "search <query>", description: "Search Are.na" },
{
usage: "search <query> --type Image",
description:
"Filter by type (Text, Image, Link, Attachment, Embed, Channel, Block, User, Group)",
},
{
usage: "search <query> --scope my",
description: "Limit scope (all, my, following)",
},
{
usage: "search <query> --sort created_at_desc",
description:
"Sort order (score_desc, created_at_desc, created_at_asc, updated_at_desc, updated_at_asc, name_asc, name_desc, connections_count_desc, random)",
},
{
usage: "search <query> --ext pdf",
description: "Filter by file extension",
},
{
usage: "search <query> --after 2024-01-01T00:00:00Z",
description: "Only results updated after timestamp (ISO 8601)",
},
{
usage: "search <query> --channel-id 789",
description:
"Limit to a channel (--user-id, --group-id also available)",
},
{
usage: "search <query> --sort random --seed 42",
description: "Reproducible random ordering",
},
],
session: { args: "<query>", desc: "Search Are.na" },
render(args, flags) {
const query = requireArg([args.join(" ")], 0, "query");
Expand All @@ -384,6 +417,14 @@ export const commands: CommandDefinition[] = [
page={optPage(flags)}
per={optPer(flags)}
type={flag(flags, "type")}
sort={flagAs<SearchSort>(flags, "sort")}
scope={flagAs<SearchScope>(flags, "scope")}
ext={flagAs<FileExtension>(flags, "ext")}
after={flag(flags, "after")}
seed={intFlag(flags, "seed")}
userId={intFlag(flags, "user-id")}
groupId={intFlag(flags, "group-id")}
channelId={intFlag(flags, "channel-id")}
/>
);
},
Expand Down
Loading