Skip to content
Open
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
32 changes: 19 additions & 13 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,26 +698,32 @@ DESCRIPTION
USAGE
$ apify actors search [query] [--category <value>]
[--json] [--limit <value>] [--offset <value>]
[--pricing-model <value>] [--sort-by <value>]
[--pricing-model
FREE|FLAT_PRICE_PER_MONTH|PRICE_PER_DATASET_ITEM|PAY_PER_EVENT]
[--sort-by relevance|popularity|newest|lastUpdate]
[--username <value>]

ARGUMENTS
query Search query to find Actors by title, name, description, username,
or readme.

FLAGS
--category=<value> Filter by category (e.g.
AI).
--json Format the command output as
JSON.
--limit=<value> Maximum number of results to
return.
--offset=<value> Number of results to skip
for pagination.
--pricing-model=<value> Filter by pricing model.
--sort-by=<value> Sort order for the results.
--username=<value> Filter by Actor author
username.
--category=<value> Filter by category (e.g.
AI).
--json Format the command output
as JSON.
--limit=<value> Maximum number of results
to return.
--offset=<value> Number of results to skip
for pagination.
--pricing-model=<option> Filter by pricing model.
<options:
FREE|FLAT_PRICE_PER_MONTH|PRICE_PER_DATASET_ITEM|PAY_PER_EVENT>
--sort-by=<option> Sort order for the
results.
<options: relevance|popularity|newest|lastUpdate>
--username=<value> Filter by Actor author
username.
```

##### `apify actors rm`
Expand Down
4 changes: 2 additions & 2 deletions src/commands/actors/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ActorsSearchCommand extends ApifyCommand<typeof ActorsSearchCommand
static override flags = {
'sort-by': Flags.string({
description: 'Sort order for the results.',
options: ['relevance', 'popularity', 'newest', 'lastUpdate'],
choices: ['relevance', 'popularity', 'newest', 'lastUpdate'],
default: 'relevance',
}),
category: Flags.string({
Expand All @@ -78,7 +78,7 @@ export class ActorsSearchCommand extends ApifyCommand<typeof ActorsSearchCommand
}),
'pricing-model': Flags.string({
description: 'Filter by pricing model.',
options: ['FREE', 'FLAT_PRICE_PER_MONTH', 'PRICE_PER_DATASET_ITEM', 'PAY_PER_EVENT'],
choices: ['FREE', 'FLAT_PRICE_PER_MONTH', 'PRICE_PER_DATASET_ITEM', 'PAY_PER_EVENT'],
}),
limit: Flags.integer({
description: 'Maximum number of results to return.',
Expand Down
7 changes: 7 additions & 0 deletions src/lib/command-framework/CommandError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ export class CommandError extends Error {
);
}

case CommandErrorCode.APIFY_INVALID_CHOICE: {
const flagName = `--${this.metadata.flag}`;
const choices = this.metadata.choices as string;

return chalk.gray(`Invalid value for flag ${chalk.white.bold(flagName)}. Expected one of: ${choices}`);
}

default: {
const cliMetadata = useCLIMetadata();

Expand Down
4 changes: 2 additions & 2 deletions src/lib/command-framework/apify-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
}

// If you have a flag a, with alias b, and you pass --a and --b, it's not allowed
const matchingFlags = allMatchers.filter((matcher) => rawFlags[matcher]);
const matchingFlags = allMatchers.filter((matcher) => Object.hasOwn(rawFlags, matcher));

if (matchingFlags.length > 1) {
throw new CommandError({
Expand Down Expand Up @@ -593,7 +593,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
// Validate choices
if (
// We have the flag
this.flags[camelCasedName] &&
this.flags[camelCasedName] != null &&
// And we have a list of choices
builderData.choices &&
// And the flag is not one of the choices
Expand Down