Skip to content

Commit d29ba54

Browse files
authored
Merge pull request #1 from bitrefill/fix/coerce-string-values
Fix string CLI arguments being passed through JSON.parse
2 parents a3e003e + f7b6e46 commit d29ba54

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ On first run, the CLI will open your browser for OAuth authorization. Credential
2727
bitrefill search-products --query "Netflix"
2828

2929
# Get product details
30-
bitrefill get_product_details --product_id "steam-usa" --currency USDC
30+
bitrefill get-product-details --product_id "steam-usa" --currency USDC
3131

3232
# Buy a product
33-
bitrefill buy_products --cart_items '{"product_id": "steam-usa", "package_id": 10}' --payment_method usdc_base
33+
bitrefill buy-products --cart_items '{"product_id": "steam-usa", "package_id": 10}' --payment_method usdc_base
3434

3535
# List your orders
3636
bitrefill list-orders

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,11 @@ function coerceValue(raw: string, prop: JsonSchemaProperty): unknown {
253253
if (['true', '1', 'yes'].includes(raw)) return true;
254254
if (['false', '0', 'no'].includes(raw)) return false;
255255
throw new Error('Must be true/false');
256-
default:
256+
case 'object':
257+
case 'array':
257258
return JSON.parse(raw);
259+
default:
260+
return raw;
258261
}
259262
}
260263

0 commit comments

Comments
 (0)