-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add CSV conversion command to ensrainbow CLI #1136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2006959
b491441
4c18e0b
5aefe9d
f2c8f20
e20932d
b9c31b0
e2b9255
2c94d41
721a50d
56bc356
11992d7
3dea60e
b6c668a
b02b7f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "ensrainbow": patch | ||
| --- | ||
|
|
||
| feat: add CSV conversion command to ensrainbow CLI | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |||||
| } from "@ensnode/ensnode-sdk"; | ||||||
|
|
||||||
| import { convertCommand } from "@/commands/convert-command"; | ||||||
| import { convertCsvCommand } from "@/commands/convert-csv-command"; | ||||||
| // import { ingestCommand } from "@/commands/ingest-command"; | ||||||
| import { ingestProtobufCommand } from "@/commands/ingest-protobuf-command"; | ||||||
| import { purgeCommand } from "@/commands/purge-command"; | ||||||
|
|
@@ -61,6 +62,16 @@ interface ConvertArgs { | |||||
| "label-set-version": LabelSetVersion; | ||||||
| } | ||||||
|
|
||||||
| interface ConvertCsvArgs { | ||||||
| "input-file": string; | ||||||
| "output-file": string; | ||||||
| "label-set-id": LabelSetId; | ||||||
| "label-set-version": LabelSetVersion; | ||||||
| "progress-interval"?: number; | ||||||
| "existing-db-path"?: string; | ||||||
| silent?: boolean; | ||||||
| } | ||||||
|
|
||||||
| export interface CLIOptions { | ||||||
| exitProcess?: boolean; | ||||||
| } | ||||||
|
|
@@ -184,7 +195,7 @@ export function createCLI(options: CLIOptions = {}) { | |||||
| ) | ||||||
| .command( | ||||||
| "convert", | ||||||
| "Convert rainbow tables from SQL dump to protobuf format", | ||||||
| "Convert rainbow tables from SQL dump to ensrainbow format", | ||||||
| (yargs: Argv) => { | ||||||
| return yargs | ||||||
| .option("input-file", { | ||||||
|
|
@@ -194,7 +205,7 @@ export function createCLI(options: CLIOptions = {}) { | |||||
| }) | ||||||
| .option("output-file", { | ||||||
| type: "string", | ||||||
| description: "Path to the output protobuf file", | ||||||
| description: "Path to the output ensrainbow file", | ||||||
| default: join(process.cwd(), "rainbow-records.ensrainbow"), | ||||||
| }) | ||||||
| .option("label-set-id", { | ||||||
|
|
@@ -219,6 +230,60 @@ export function createCLI(options: CLIOptions = {}) { | |||||
| }); | ||||||
| }, | ||||||
| ) | ||||||
| .command( | ||||||
| "convert-csv", | ||||||
| "Convert rainbow tables from CSV format to ensrainbow format", | ||||||
| (yargs: Argv) => { | ||||||
| return yargs | ||||||
| .option("input-file", { | ||||||
| type: "string", | ||||||
| description: "Path to the CSV input file", | ||||||
| demandOption: true, | ||||||
| }) | ||||||
| .option("output-file", { | ||||||
| type: "string", | ||||||
| description: "Path to the output ensrainbow file", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| default: join(process.cwd(), "rainbow-records.ensrainbow"), | ||||||
| }) | ||||||
| .option("label-set-id", { | ||||||
| type: "string", | ||||||
| description: "Label set id for the rainbow record collection", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| demandOption: true, | ||||||
| }) | ||||||
| .coerce("label-set-id", buildLabelSetId) | ||||||
| .option("label-set-version", { | ||||||
| type: "number", | ||||||
| description: "Label set version for the rainbow record collection", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| demandOption: true, | ||||||
| }) | ||||||
| .coerce("label-set-version", buildLabelSetVersion) | ||||||
| .option("progress-interval", { | ||||||
| type: "number", | ||||||
| description: "Number of records to process before logging progress", | ||||||
| default: 50000, | ||||||
| }) | ||||||
| .option("existing-db-path", { | ||||||
| type: "string", | ||||||
| description: "Path to existing ENSRainbow database to filter out existing labels", | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| }) | ||||||
| .option("silent", { | ||||||
| type: "boolean", | ||||||
| description: "Disable progress bar (useful for scripts)", | ||||||
| default: false, | ||||||
| }); | ||||||
| }, | ||||||
| async (argv: ArgumentsCamelCase<ConvertCsvArgs>) => { | ||||||
| await convertCsvCommand({ | ||||||
| inputFile: argv["input-file"], | ||||||
| outputFile: argv["output-file"], | ||||||
| labelSetId: argv["label-set-id"], | ||||||
| labelSetVersion: argv["label-set-version"], | ||||||
| progressInterval: argv["progress-interval"], | ||||||
| existingDbPath: argv["existing-db-path"], | ||||||
| silent: argv["silent"], | ||||||
| }); | ||||||
| }, | ||||||
| ) | ||||||
| .demandCommand(1, "You must specify a command") | ||||||
| .fail((msg, err, yargs) => { | ||||||
| if (process.env.VITEST) { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.