Skip to content

Commit

Permalink
Add filter for enabled nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheran-senthil committed Oct 31, 2024
1 parent dc1e325 commit 2d72c93
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/commands/project/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import { formatProject, getAll, getContract, getProvider, parseAddress, pretty }
export default class ProjectList extends BlockchainCommand {
static summary = "List projects on the EarthFast Network.";
static examples = ["<%= config.bin %> <%= command.id %>"];
static usage = "<%= command.id %> [--owner ADDR] [--skip N] [--size N] [--page N]";
static usage = "<%= command.id %> [--owner ADDR] [--skip N] [--size N] [--page N] [--enabled-only]";
static flags = {
owner: Flags.string({ description: "Filter by owner address.", helpValue: "ADDR" }),
skip: Flags.integer({ description: "The number of results to skip.", helpValue: "N", default: 0 }),
size: Flags.integer({ description: "The number of results to list.", helpValue: "N", default: 100 }),
page: Flags.integer({ description: "The contract call paging size.", helpValue: "N", default: 100 }),
enabledOnly: Flags.boolean({
description: "Show only enabled nodes.",
default: false,
char: "e",
}),
};

public async run(): Promise<Record<string, unknown>[]> {
Expand All @@ -26,6 +31,9 @@ export default class ProjectList extends BlockchainCommand {
if (flags.owner) {
results = results.filter((v) => v.owner.toLowerCase() === owner.toLowerCase());
}
if (flags.enabledOnly) {
results = results.filter((v) => !v.disabled);
}

const records = results.slice(flags.skip, flags.skip + flags.size);
const output = records.map((r) => formatProject(r));
Expand Down

0 comments on commit 2d72c93

Please sign in to comment.