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
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ listenhub openapi subscription -j

### Images

| Command | Description |
| -------------------------- | -------------------- |
| `listenhub image create` | Generate an AI image |
| `listenhub image list` | List AI images |
| `listenhub image get <id>` | Get image details |
| Command | Description |
| -------------------------------- | ---------------------------- |
| `listenhub image create` | Generate an AI image |
| `listenhub image list` | List AI images |
| `listenhub image get <id>` | Get image details |
| `listenhub image delete <id...>` | Delete one or more AI images |

### Video Generation

Expand Down
11 changes: 6 additions & 5 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ listenhub openapi subscription -j

### 图片

| 命令 | 说明 |
| -------------------------- | ------------ |
| `listenhub image create` | AI 生图 |
| `listenhub image list` | 列出图片 |
| `listenhub image get <id>` | 查看图片详情 |
| 命令 | 说明 |
| -------------------------------- | ------------------ |
| `listenhub image create` | AI 生图 |
| `listenhub image list` | 列出图片 |
| `listenhub image get <id>` | 查看图片详情 |
| `listenhub image delete <id...>` | 删除一个或多个图片 |

### 视频生成

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@marswave/listenhub-cli",
"version": "0.0.10",
"version": "0.0.11",
"description": "Command-line interface for ListenHub",
"license": "MIT",
"repository": "marswaveai/listenhub-cli",
Expand All @@ -25,7 +25,7 @@
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@marswave/listenhub-sdk": "^0.0.11",
"@marswave/listenhub-sdk": "^0.0.13",
"commander": "^14.0.3",
"open": "^10.0.0",
"ora": "^8.0.0"
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions source/image/_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
type ImageCreateOptions,
type ImageListOptions,
createImage,
deleteImages,
getImage,
listImages,
} from './image.js';
Expand Down Expand Up @@ -75,4 +76,17 @@ export function register(program: Command) {
handleError(error, options.json);
}
});

cmd
.command('delete <id...>')
.description('Delete one or more AI images')
.option('-j, --json', 'Output JSON', false)
.action(async (ids: string[], options: {json: boolean}) => {
try {
const client = await getClient();
await deleteImages(client, ids, options.json);
} catch (error) {
handleError(error, options.json);
}
});
}
14 changes: 14 additions & 0 deletions source/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,17 @@ export async function getImage(
['Created:', new Date(item.createdAt).toISOString()],
]);
}

export async function deleteImages(
client: ListenHubClient,
ids: string[],
json: boolean,
): Promise<void> {
await client.deleteAIImages({ids});

if (json) {
printJson({deleted: ids});
} else {
console.log(`✓ Deleted ${String(ids.length)} image(s)`);
}
}
Loading