{"version":3,"sources":["../src/cli.ts"],"names":["androidPriorityOptions","unknown","alias","boolean","default","describe","verbose","debug","info","warn","error","fatal","silent","iosPriorityOptions","argv","_","platform","filter","args","yargs","usage","command","demandCommand","option","type","nargs","example","help","version","selectedAndroidPriorities","Boolean","selectedIosPriorities","createFilter","appId","tags","regexes","map","value","RegExp","patterns","emitter","adbPath","String","priority","AndroidPriority","DEBUG","IosPriority","DEFAULT","on","entry","process","stdout","write","terminate","console","log","exit"],"mappings":";;AAAA;;AACA;;AAUA;;AAEA;;;;AAGA,MAAMA,sBAAsB,GAAG;AAC7BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,KAAK,EAAE,CAAC,GAAD,EAAM,GAAN,CADA;AAEPC,IAAAA,OAAO,EAAE,IAFF;AAGPC,IAAAA,OAAO,EAAE,KAHF;AAIPC,IAAAA,QAAQ,EAAE;AAJH,GADoB;AAO7BC,EAAAA,OAAO,EAAE;AACPJ,IAAAA,KAAK,EAAE,CAAC,GAAD,EAAM,GAAN,CADA;AAEPC,IAAAA,OAAO,EAAE,IAFF;AAGPC,IAAAA,OAAO,EAAE,KAHF;AAIPC,IAAAA,QAAQ,EAAE;AAJH,GAPoB;AAa7BE,EAAAA,KAAK,EAAE;AACLL,IAAAA,KAAK,EAAE,CAAC,GAAD,EAAM,GAAN,CADF;AAELC,IAAAA,OAAO,EAAE,IAFJ;AAGLC,IAAAA,OAAO,EAAE,KAHJ;AAILC,IAAAA,QAAQ,EAAE;AAJL,GAbsB;AAmB7BG,EAAAA,IAAI,EAAE;AACJN,IAAAA,KAAK,EAAE,CAAC,GAAD,EAAM,GAAN,CADH;AAEJC,IAAAA,OAAO,EAAE,IAFL;AAGJC,IAAAA,OAAO,EAAE,KAHL;AAIJC,IAAAA,QAAQ,EAAE;AAJN,GAnBuB;AAyB7BI,EAAAA,IAAI,EAAE;AACJP,IAAAA,KAAK,EAAE,CAAC,GAAD,EAAM,GAAN,CADH;AAEJC,IAAAA,OAAO,EAAE,IAFL;AA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S2C,SAAT,CAAmB3C,KAAnB,EAA6C;AAC3C;AACA4C,EAAAA,OAAO,CAACC,GAAR,CAAY,6BAAY7C,KAAZ,CAAZ;AACAwC,EAAAA,OAAO,CAACM,IAAR,CAAa,CAAb;AACD","sourcesContent":["import yargs from 'yargs';\nimport {\n logkitty,\n makeAppFilter,\n makeTagsFilter,\n makeMatchFilter,\n makeCustomFilter,\n FilterCreator,\n AndroidPriority,\n IosPriority,\n} from './api';\nimport { formatEntry, formatError } from './formatters';\nimport { CodeError } from './errors';\nimport { getMinPriority } from './utils';\nimport { Entry, Platform } from './types';\n\nconst androidPriorityOptions = {\n unknown: {\n alias: ['U', 'u'],\n boolean: true,\n default: false,\n describe: 'Unknown priority',\n },\n verbose: {\n alias: ['V', 'v'],\n boolean: true,\n default: false,\n describe: 'Verbose priority',\n },\n debug: {\n alias: ['D', 'd'],\n boolean: true,\n default: false,\n describe: 'Debug priority',\n },\n info: {\n alias: ['I', 'i'],\n boolean: true,\n default: false,\n describe: 'Info priority',\n },\n warn: {\n alias: ['W', 'w'],\n boolean: true,\n default: false,\n describe: 'Warn priority',\n },\n error: {\n alias: ['E', 'e'],\n boolean: true,\n default: false,\n describe: 'Error priority',\n },\n fatal: {\n alias: ['F', 'f'],\n boolean: true,\n default: false,\n describe: 'Fatal priority',\n },\n silent: {\n alias: ['S', 's'],\n boolean: true,\n default: false,\n describe: 'Silent priority',\n },\n};\n\nconst iosPriorityOptions = {\n debug: {\n alias: ['D', 'd'],\n boolean: true,\n default: false,\n describe: 'Debug level',\n },\n info: {\n alias: ['I', 'i'],\n boolean: true,\n default: false,\n describe: 'Info level',\n },\n error: {\n alias: ['E', 'e'],\n boolean: true,\n default: false,\n describe: 'Error level',\n },\n};\n\nconst {\n argv: {\n _: [platform, filter],\n ...args\n },\n} = yargs\n .usage('Usage: $0 [options] ')\n .command('android', 'Android', yargs =>\n yargs\n .command(\n 'tag ',\n 'Show logs matching given tags',\n androidPriorityOptions\n )\n .command(\n 'app ',\n 'Show logs from application with given identifier',\n androidPriorityOptions\n )\n .command(\n 'match ',\n 'Show logs matching given patterns',\n androidPriorityOptions\n )\n .command(\n 'custom ',\n 'Filter using custom patterns :'\n )\n .command('all', 'Show all logs', androidPriorityOptions)\n .demandCommand(1)\n .option('adb-path', {\n type: 'string',\n describe: 'Use custom path to adb',\n nargs: 1,\n })\n .example(\n '$0 android tag MyTag',\n 'Filter logs to only include ones with MyTag tag'\n )\n .example(\n '$0 android tag MyTag -I',\n 'Filter logs to only include ones with MyTag tag and priority INFO and above'\n )\n .example(\n '$0 android app com.example.myApp',\n 'Show all logs from com.example.myApp'\n )\n .example(\n '$0 android match device',\n 'Show all logs matching /device/gm regex'\n )\n .example(\n '$0 android app com.example.myApp -E',\n 'Show all logs from com.example.myApp with priority ERROR and above'\n )\n .example(\n '$0 android custom *:S MyTag:D',\n 'Silence all logs and show only ones with MyTag with priority DEBUG and above'\n )\n )\n .command('ios ', 'iOS', yargs =>\n yargs\n .command(\n 'tag ',\n 'Show logs matching given tags',\n iosPriorityOptions\n )\n .command(\n 'match ',\n 'Show logs matching given patterns',\n iosPriorityOptions\n )\n .command('all', 'Show all logs', iosPriorityOptions)\n .demandCommand(1)\n .example(\n '$0 ios tag MyTag',\n 'Filter logs to only include ones with MyTag tag'\n )\n .example(\n '$0 ios tag MyTag -i',\n 'Filter logs to only include ones with MyTag tag and priority Info and Error'\n )\n .example('$0 ios match device', 'Show all logs matching /device/gm regex')\n )\n .demandCommand(1)\n .help('h')\n .alias('h', 'help')\n .alias('v', 'version')\n .version();\n\nconst selectedAndroidPriorities = {\n unknown: Boolean(args.unknown),\n verbose: Boolean(args.verbose),\n debug: Boolean(args.debug),\n info: Boolean(args.info),\n warn: Boolean(args.warn),\n error: Boolean(args.error),\n fatal: Boolean(args.fatal),\n silent: Boolean(args.silent),\n};\n\nconst selectedIosPriorities = {\n debug: Boolean(args.debug),\n info: Boolean(args.info),\n error: Boolean(args.error),\n};\n\ntry {\n let createFilter: FilterCreator | undefined;\n switch (filter) {\n case 'app':\n createFilter = makeAppFilter(args.appId as string);\n break;\n case 'tag':\n createFilter = makeTagsFilter(...(args.tags as string[]));\n break;\n case 'match':\n createFilter = makeMatchFilter(\n ...(args.regexes as string[]).map(\n (value: string) => new RegExp(value, 'gm')\n )\n );\n break;\n case 'custom':\n createFilter = makeCustomFilter(...(args.patterns as string[]));\n break;\n case 'all':\n default:\n }\n const emitter = logkitty({\n platform: platform as Platform,\n adbPath: args.adbPath ? String(args.adbPath) : '',\n priority:\n platform === 'android'\n ? getMinPriority(\n AndroidPriority,\n selectedAndroidPriorities,\n AndroidPriority.DEBUG\n )\n : getMinPriority(\n IosPriority,\n selectedIosPriorities,\n IosPriority.DEFAULT\n ),\n filter: createFilter,\n });\n\n emitter.on('entry', (entry: Entry) => {\n process.stdout.write(formatEntry(entry));\n });\n\n emitter.on('error', (error: Error) => {\n terminate(error);\n });\n} catch (error) {\n terminate(error as Error | CodeError);\n}\n\nfunction terminate(error: CodeError | Error) {\n // eslint-disable-next-line no-console\n console.log(formatError(error));\n process.exit(1);\n}\n"],"file":"cli.js"}