Usage: discount-code-gen [options]
Options:
--help, -h Show help text. [boolean]
--version, -v Show version number. [boolean]
--quantity, -q Quantity of discount codes to generate. (Between 1 and 500000) [required]
--code-length, -l Length of the discount codes to generate. [default: 11]
--code-prefix, -p Prefix for each code. No prefix will be used if omitted. [default: ""]
--input, -i Path to code options CSV or JSON file.
--output, -o Path to store generated output file. [default: "stdout"]
--delimiter, -d Used CSV delimiter for input and/or output file. [default: ","]
--multiValueDelimiter, -m Used CSV delimiter in multiValue fields for input/output file. [default: ";"]
--logLevel, Logging level: error, warn, info or verbose. [default: "info"]
Info on flags
The --quantity flag represents the number of codes to be generated. It must be a number between 1 and 500000
The --code-length flag is used to customise the discount codes according to individual use cases. (more info in Examples)
The --input flag specifies the path to a CSV or JSON file containing the options the discount codes should have. If this flag is omitted, discount codes without any attributes will be generated.
The --output flag specifies where to output/save the generated codes. Several notes on this flag:
The format of the generated output will depend on the format of the file specified here. It must be CSV or JSON as these are the only supported formats.
If the file specified already exists, it will be overwritten.
The default location for status report logging is the standard output.
If no output path is specified, the generated codes will be logged to the standard output as a result, status reports will be logged to a discountCodeGenerator.log file
The --delimiter flag specifies the delimiter used in the input file and/or output file if any or both are CSV. Defaults to ',' if omitted and will be ignored if neither input nor output is CSV
The --multiValueDelimiter flag specifies the delimiter for multiValue cells in CSV. Note that only the cartDiscounts field if present should contain multiple values. Defaults to ';' if omitted
Examples
CSV
If we want to generate 3 discount codes, each having 9 characters(code-length), 'FOO' as prefix, and having the following data stored in a CSV file:
name.en,name.de,description.en,description.de,cartDiscounts,cartPredicate,isActive,maxApplications,maxApplicationsPerCustomer
Sammy,Valerian,greatest promo,super angebot,good;better;best,value more than 20,true,10,2
and also wanting a CSV output, we would run the following command
The following would be written to the output file:
"name.en","name.de","description.en","description.de","cartDiscounts","cartPredicate","isActive","maxApplications","maxApplicationsPerCustomer","code"
"Sammy","Valerian","greatest promo","super angebot","good;better;best","value more than 20","true","10","2","FOObcXdOd"
"Sammy","Valerian","greatest promo","super angebot","good;better;best","value more than 20","true","10","2","FOOiNfQyy"
"Sammy","Valerian","greatest promo","super angebot","good;better;best","value more than 20","true","10","2","FOONtF2XL"
JSON
If we want to generate 3 discount codes, each having 9 characters(code-length), 'FOO' as prefix, and having the following data stored in a JSON file: