diff --git a/scripts/commands/epg/grab.ts b/scripts/commands/epg/grab.ts index b3323a86..cdaba5a1 100644 --- a/scripts/commands/epg/grab.ts +++ b/scripts/commands/epg/grab.ts @@ -1,32 +1,48 @@ import { Logger, Timer, Storage, Collection } from '@freearhey/core' -import { program } from 'commander' +import { Option, program } from 'commander' import { QueueCreator, Job, ChannelsParser } from '../../core' import { Channel } from 'epg-grabber' import path from 'path' import { SITES_DIR } from '../../constants' program - .option('-s, --site ', 'Name of the site to parse') - .option( - '-c, --channels ', - 'Path to *.channels.xml file (required if the "--site" attribute is not specified)' + .addOption(new Option('-s, --site ', 'Name of the site to parse')) + .addOption( + new Option( + '-c, --channels ', + 'Path to *.channels.xml file (required if the "--site" attribute is not specified)' + ) ) - .option('-o, --output ', 'Path to output file', 'guide.xml') - .option('-l, --lang ', 'Filter channels by language (ISO 639-2 code)') - .option('-t, --timeout ', 'Override the default timeout for each request') - .option('-d, --delay ', 'Override the default delay between request') - .option( - '--days ', - 'Override the number of days for which the program will be loaded (defaults to the value from the site config)', - value => parseInt(value) + .addOption(new Option('-o, --output ', 'Path to output file').default('guide.xml')) + .addOption(new Option('-l, --lang ', 'Filter channels by language (ISO 639-2 code)')) + .addOption( + new Option('-t, --timeout ', 'Override the default timeout for each request').env( + 'TIMEOUT' + ) ) - .option( - '--maxConnections ', - 'Limit on the number of concurrent requests', - value => parseInt(value), - 1 + .addOption( + new Option('-d, --delay ', 'Override the default delay between request').env( + 'DELAY' + ) + ) + .addOption( + new Option( + '--days ', + 'Override the number of days for which the program will be loaded (defaults to the value from the site config)' + ) + .argParser(value => parseInt(value)) + .env('DAYS') + ) + .addOption( + new Option('--maxConnections ', 'Limit on the number of concurrent requests') + .default(1) + .env('MAX_CONNECTIONS') + ) + .addOption( + new Option('--gzip', 'Create a compressed version of the guide as well') + .default(false) + .env('GZIP') ) - .option('--gzip', 'Create a compressed version of the guide as well', false) .parse(process.argv) export type GrabOptions = {