From 0ad13284cf216bd995ba2b9568dc985e3f25288c Mon Sep 17 00:00:00 2001 From: the-masthead <116779271+the-masthead@users.noreply.github.com> Date: Thu, 3 Nov 2022 11:43:06 -0700 Subject: [PATCH] Switch to comma separated node ida --- src/commands/reservation/create.ts | 12 +++--------- src/commands/reservation/delete.ts | 13 +++---------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/commands/reservation/create.ts b/src/commands/reservation/create.ts index eb10a20..537a9ef 100644 --- a/src/commands/reservation/create.ts +++ b/src/commands/reservation/create.ts @@ -9,10 +9,9 @@ export default class ReservationCreate extends TransactionCommand { By default, new reservations begin at the start of the next epoch.`; static examples = ["<%= config.bin %> <%= command.id %> 0x123abc... 0x456def..."]; static usage = "<%= command.id %> ID IDS... [--spot] [--norenew]"; - static strict = false; static args: Arg[] = [ { name: "ID", description: "The ID of the project to reserve the nodes.", required: true }, - { name: "IDS", description: "The IDs of the nodes to reserve for the project.", required: true }, + { name: "IDS", description: "The comma separated IDs of the nodes to reserve.", required: true }, ]; static flags = { spot: Flags.boolean({ description: "Reserve in the current epoch (can't release!)" }), @@ -20,17 +19,12 @@ export default class ReservationCreate extends TransactionCommand { }; public async run(): Promise[]> { - const { args, flags, raw } = await this.parse(ReservationCreate); + const { args, flags } = await this.parse(ReservationCreate); if (!flags.spot && !!flags.norenew) { this.error("--norenew requires --spot"); } - // Parse vararg IDS - const nodeIds = raw - .filter((arg) => arg.type == "arg") - .map((arg) => arg.input) - .slice(1) // Skip ID - .map((id) => normalizeHash(id)); + const nodeIds = args.IDS.split(",").map((id: string) => normalizeHash(id)); const signer = await getSigner(flags.network, flags.rpc, flags.address, flags.signer); const reservations = await getContract(flags.network, flags.abi, "ArmadaReservations", signer); const projectId = normalizeHash(args.ID); diff --git a/src/commands/reservation/delete.ts b/src/commands/reservation/delete.ts index 6a737cb..7da1f3f 100644 --- a/src/commands/reservation/delete.ts +++ b/src/commands/reservation/delete.ts @@ -8,21 +8,14 @@ export default class ReservationDelete extends TransactionCommand { The reservations will be deleted starting from the next epoch.`; static examples = ["<%= config.bin %> <%= command.id %> 0x123abc... 0x456def..."]; static usage = "<%= command.id %> ID IDS..."; - static strict = false; static args: Arg[] = [ { name: "ID", description: "The ID of the project to release the nodes.", required: true }, - { name: "IDS", description: "The IDs of the nodes to release from the project.", required: true }, + { name: "IDS", description: "The comma separated IDs of the nodes to release.", required: true }, ]; public async run(): Promise[]> { - const { args, flags, raw } = await this.parse(ReservationDelete); - // Parse vararg IDS - const nodeIds = raw - .filter((arg) => arg.type == "arg") - .map((arg) => arg.input) - .slice(1) // Skip ID - .map((id) => normalizeHash(id)); - + const { args, flags } = await this.parse(ReservationDelete); + const nodeIds = args.IDS.split(",").map((id: string) => normalizeHash(id)); const signer = await getSigner(flags.network, flags.rpc, flags.address, flags.signer); const reservations = await getContract(flags.network, flags.abi, "ArmadaReservations", signer); const projectId = normalizeHash(args.ID);