Skip to content

Commit

Permalink
feat: connect getMediaFilesNames
Browse files Browse the repository at this point in the history
  • Loading branch information
timgreen committed Mar 10, 2023
1 parent 08bc6a2 commit 56190e6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/cli/src/commands/connect/getMediaFilesNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { invoke } from "@autoanki/anki-connect";
import { Args, Command } from "@oclif/core";

export default class GetMediaFilesNames extends Command {
static description =
"Gets the names of media files matched the pattern. Returning all names by default.";

static strict = true;
static enableJsonFlag = true;

static args = {
pattern: Args.string({
required: false,
description: "Pattern",
default: "",
}),
};

static examples = [
"<%= config.bin %> <%= command.id %> getMediaFilesNames",
"<%= config.bin %> <%= command.id %> getMediaFilesNames pattern",
];

public async run(): Promise<string[]> {
const { args } = await this.parse(GetMediaFilesNames);

const mediaFilesNames = await invoke({
action: "getMediaFilesNames",
version: 6,
request: {
pattern: args.pattern,
},
});
this.log(mediaFilesNames.join("\n"));

return mediaFilesNames;
}
}

0 comments on commit 56190e6

Please sign in to comment.