#!/usr/bin/env node

import { split } from "./split";

const inFile = process.argv[2];
const outFile = process.argv[3];
const maxDepthArg = process.argv[4];

// Check if the number of arguments is less than expected
if (process.argv.length < 4) {
	console.error("Please specify all command line arguments:");
	console.error("split ./path/to/large_postman_collection.json ./path/to/postman_collection_with_refs.json [maxDepth]");
	process.exit(1);
}

// If maxDepthArg is provided, parse it as a number. Otherwise, set it to undefined.
const maxDepth = maxDepthArg ? parseInt(maxDepthArg, 10) : undefined;

split(inFile, outFile, maxDepth)