import yargs, { Arguments } from 'yargs' import { ConfigureCommand, Global, GlobalOptions } from '@nativecode/media-cli' import env from './env' import { Load } from './config' import ListCommand, { ListOptions } from './commands/list' import ShowCommand, { ShowOptions } from './commands/show' import EpisodesCommand, { EpisodeOptions } from './commands/episodes' import CalendarCommand, { CalendarOptions } from './commands/calendar' GlobalOptions(yargs) .scriptName('sonarr-cli') .command('$0 ', false) .command(new ConfigureCommand('.sonarrrc.json')) .command(CalendarCommand) .command(ListCommand) .command(EpisodesCommand) .command(ShowCommand) .middleware(async (args: Arguments) => { args = env(args) await Load(args) if (process.env.DEBUG) { console.log(args) } }) .showHelpOnFail(true) .help() .parse()