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
48 changes: 29 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@ Running `arena` with no arguments opens an interactive session. Pass a command f
```bash
arena channel worldmaking # View a channel
arena channel contents worldmaking # Paginated contents
arena channel contents worldmaking --sort updated_at_desc --user-id 123
arena channel create "My Research" --visibility private
arena channel create "Team Notes" --group-id 123
arena channel update my-research --title "New Title" --description "Updated"
arena channel delete my-research
arena channel connections worldmaking # Where channel appears
arena channel followers worldmaking
arena channel connections worldmaking --sort connected_at_desc
arena channel followers worldmaking --sort connected_at_desc
```

### Blocks

```bash
arena block 12345 # View a block
arena block update 12345 --title "New Title"
arena block comments 12345 # View comments
arena block connections 12345 # Where block appears
arena block comments 12345 --sort connected_at_desc
arena block connections 12345 --sort connected_at_desc --filter OWN
arena add my-channel "Hello world" # Add text
arena add my-channel https://example.com # Add a URL
arena add my-channel "Hello" --title "Greeting" --description "Pinned note"
arena add my-channel https://example.com --alt-text "Cover image" --insert-at 1
arena add my-channel https://example.com --original-source-url https://source.com --original-source-title "Original"
arena upload photo.jpg --channel my-channel
arena batch my-channel "https://a.com" "https://b.com"
arena batch status 1234
Expand All @@ -66,8 +71,10 @@ echo "piped text" | arena add my-channel

```bash
arena connect 12345 my-channel # Connect block to channel
arena connect 12345 my-channel --type Channel --position 1
arena connection 67890 # View a connection
arena connection move 67890 --movement move_to_top
arena connection move 67890 --movement insert_at --position 1
arena connection delete 67890
```

Expand All @@ -83,12 +90,12 @@ arena comment delete 67890
```bash
arena whoami # Current user
arena user damon-zucconi # View a user
arena user contents damon-zucconi # User's content
arena user followers damon-zucconi
arena user following damon-zucconi
arena user contents damon-zucconi --type Image --sort updated_at_desc
arena user followers damon-zucconi --sort connected_at_desc
arena user following damon-zucconi --type User --sort connected_at_desc
arena group are-na-team # View a group
arena group contents are-na-team # Group's content
arena group followers are-na-team
arena group contents are-na-team --type Image --sort updated_at_desc
arena group followers are-na-team --sort connected_at_desc
```

### Search
Expand Down Expand Up @@ -134,16 +141,19 @@ arena ping # API health check

### Command-specific flags

| Command | Flags |
| ---------------------------------- | -------------------------------------------------------------------------------------------------- |
| `channel create`, `channel update` | `--title`, `--description`, `--visibility` |
| `block update` | `--title`, `--description`, `--content`, `--alt-text` |
| `add`, `batch` | `--title`, `--description` |
| `upload` | `--channel`, `--title`, `--description` |
| `connect` | `--type`, `--position` |
| `connection move` | `--movement`, `--position` |
| `search` | `--scope`, `--sort`, `--ext`, `--after`, `--seed`, `--user-id`, `--group-id`, `--channel-id` |
| `import` | `--dir`, `--recursive`, `--interactive`, `--batch-size`, `--upload-concurrency`, `--poll-interval` |
| Command | Flags |
| ------------------ | ----------------------------------------------------------------------------------------------------------- |
| `channel create` | `--description`, `--visibility`, `--group-id` |
| `channel update` | `--title`, `--description`, `--visibility` |
| `channel contents` | `--user-id` |
| `block update` | `--title`, `--description`, `--content`, `--alt-text` |
| `add` | `--title`, `--description`, `--alt-text`, `--original-source-url`, `--original-source-title`, `--insert-at` |
| `batch` | `--title`, `--description` |
| `upload` | `--channel`, `--title`, `--description` |
| `connect` | `--type`, `--position` |
| `connection move` | `--movement`, `--position` |
| `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
27 changes: 25 additions & 2 deletions src/commands/add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@ import { useCommand } from "../hooks/use-command";
interface Props {
channel: string;
value: string;
title?: string;
description?: string;
altText?: string;
originalSourceUrl?: string;
originalSourceTitle?: string;
insertAt?: number;
}

export function AddCommand({ channel, value, description }: Props) {
export function AddCommand({
channel,
value,
title,
description,
altText,
originalSourceUrl,
originalSourceTitle,
insertAt,
}: Props) {
const { data, error, loading } = useCommand(async () => {
const ch = await getData(
client.GET("/v3/channels/{id}", {
Expand All @@ -18,7 +32,16 @@ export function AddCommand({ channel, value, description }: Props) {
);
const block = await getData(
client.POST("/v3/blocks", {
body: { value, channel_ids: [ch.id], description },
body: {
value,
channel_ids: [ch.id],
title,
description,
alt_text: altText,
original_source_url: originalSourceUrl,
original_source_title: originalSourceTitle,
insert_at: insertAt,
},
}),
);
return { block, channel: ch };
Expand Down
5 changes: 4 additions & 1 deletion src/commands/block.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Text } from "ink";
import { client, getData } from "../api/client";
import type { ConnectionSort } from "../api/types";
import { BlockContent } from "../components/BlockContent";
import { Spinner } from "../components/Spinner";
import { useCommand } from "../hooks/use-command";
Expand Down Expand Up @@ -60,15 +61,17 @@ export function BlockCommentsCommand({
id,
page = 1,
per,
sort,
}: {
id: number;
page?: number;
per?: number;
sort?: ConnectionSort;
}) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/blocks/{id}/comments", {
params: { path: { id }, query: { page, per } },
params: { path: { id }, query: { page, per, sort } },
}),
),
);
Expand Down
12 changes: 9 additions & 3 deletions src/commands/channel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Text, useApp } from "ink";
import { client, getData } from "../api/client";
import type { Visibility } from "../api/types";
import type { ChannelContentSort, Visibility } from "../api/types";
import { BlockItem } from "../components/BlockItem";
import { ChannelBlockViewer } from "../components/ChannelBlockViewer";
import {
Expand Down Expand Up @@ -175,17 +175,21 @@ export function ChannelContentsCommand({
slug,
page = 1,
per = 24,
sort,
userId,
}: {
slug: string;
page?: number;
per?: number;
sort?: ChannelContentSort;
userId?: number;
}) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/channels/{id}/contents", {
params: {
path: { id: slug },
query: { page, per, sort: "position_desc" },
query: { page, per, sort: sort ?? "position_desc", user_id: userId },
},
}),
),
Expand Down Expand Up @@ -223,15 +227,17 @@ export function ChannelCreateCommand({
title,
visibility,
description,
groupId,
}: {
title: string;
visibility?: Visibility;
description?: string;
groupId?: number;
}) {
const { data, error, loading } = useCommand(() =>
getData(
client.POST("/v3/channels", {
body: { title, visibility, description },
body: { title, visibility, description, group_id: groupId },
}),
),
);
Expand Down
13 changes: 11 additions & 2 deletions src/commands/connect.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Box, Text } from "ink";
import { client, getData } from "../api/client";
import type { ConnectableType } from "../api/types";
import { Spinner } from "../components/Spinner";
import { useCommand } from "../hooks/use-command";

interface Props {
blockId: number;
channel: string;
connectableType?: ConnectableType;
position?: number;
}

export function ConnectCommand({ blockId, channel }: Props) {
export function ConnectCommand({
blockId,
channel,
connectableType = "Block",
position,
}: Props) {
const { data, error, loading } = useCommand(async () => {
const ch = await getData(
client.GET("/v3/channels/{id}", {
Expand All @@ -19,8 +27,9 @@ export function ConnectCommand({ blockId, channel }: Props) {
await client.POST("/v3/connections", {
body: {
connectable_id: blockId,
connectable_type: "Block",
connectable_type: connectableType,
channel_ids: [ch.id],
position,
},
});
return { channel: ch };
Expand Down
16 changes: 12 additions & 4 deletions src/commands/connection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Text } from "ink";
import { client, getData } from "../api/client";
import type { Movement } from "../api/types";
import type { ConnectionFilter, ConnectionSort, Movement } from "../api/types";
import { Spinner } from "../components/Spinner";
import { useCommand } from "../hooks/use-command";
import { plural } from "../lib/format";
Expand Down Expand Up @@ -87,15 +87,19 @@ export function BlockConnectionsCommand({
id,
page = 1,
per,
sort,
filter,
}: {
id: number;
page?: number;
per?: number;
sort?: ConnectionSort;
filter?: ConnectionFilter;
}) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/blocks/{id}/connections", {
params: { path: { id }, query: { page, per } },
params: { path: { id }, query: { page, per, sort, filter } },
}),
),
);
Expand Down Expand Up @@ -132,15 +136,17 @@ export function ChannelConnectionsCommand({
slug,
page = 1,
per,
sort,
}: {
slug: string;
page?: number;
per?: number;
sort?: ConnectionSort;
}) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/channels/{id}/connections", {
params: { path: { id: slug }, query: { page, per } },
params: { path: { id: slug }, query: { page, per, sort } },
}),
),
);
Expand Down Expand Up @@ -177,15 +183,17 @@ export function ChannelFollowersCommand({
slug,
page = 1,
per,
sort,
}: {
slug: string;
page?: number;
per?: number;
sort?: ConnectionSort;
}) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/channels/{id}/followers", {
params: { path: { id: slug }, query: { page, per } },
params: { path: { id: slug }, query: { page, per, sort } },
}),
),
);
Expand Down
19 changes: 16 additions & 3 deletions src/commands/group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Box, Text } from "ink";
import { client, getData } from "../api/client";
import type { ContentTypeFilter } from "../api/types";
import type {
ConnectionSort,
ContentSort,
ContentTypeFilter,
} from "../api/types";
import { BlockItem } from "../components/BlockItem";
import { Spinner } from "../components/Spinner";
import { useCommand } from "../hooks/use-command";
Expand Down Expand Up @@ -42,20 +46,27 @@ interface GroupContentsProps {
page?: number;
per?: number;
type?: string;
sort?: ContentSort;
}

export function GroupContentsCommand({
slug,
page = 1,
per,
type,
sort,
}: GroupContentsProps) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/groups/{id}/contents", {
params: {
path: { id: slug },
query: { page, per, type: type as ContentTypeFilter | undefined },
query: {
page,
per,
type: type as ContentTypeFilter | undefined,
sort,
},
},
}),
),
Expand Down Expand Up @@ -84,17 +95,19 @@ interface GroupFollowersProps {
slug: string;
page?: number;
per?: number;
sort?: ConnectionSort;
}

export function GroupFollowersCommand({
slug,
page = 1,
per,
sort,
}: GroupFollowersProps) {
const { data, error, loading } = useCommand(() =>
getData(
client.GET("/v3/groups/{id}/followers", {
params: { path: { id: slug }, query: { page, per } },
params: { path: { id: slug }, query: { page, per, sort } },
}),
),
);
Expand Down
Loading
Loading