()
| 26 | } |
| 27 | |
| 28 | export default function cli(): void { |
| 29 | let insecureAccess = false |
| 30 | let hideQRCode = false |
| 31 | let keepOrphans = false |
| 32 | let customPluginPath: string | undefined |
| 33 | let strictPluginResolution = false |
| 34 | let noLogTimestamps = false |
| 35 | let debugModeEnabled = false |
| 36 | let forceColourLogging = false |
| 37 | let customStoragePath: string | undefined |
| 38 | |
| 39 | let shuttingDown = false |
| 40 | |
| 41 | const program = new Command() |
| 42 | program |
| 43 | .version(getVersion()) |
| 44 | .allowExcessArguments() |
| 45 | .option('-C, --color', 'force color in logging', () => forceColourLogging = true) |
| 46 | .option('-D, --debug', 'turn on debug level logging', () => debugModeEnabled = true) |
| 47 | .option('-I, --insecure', 'allow unauthenticated requests (for easier hacking)', () => insecureAccess = true) |
| 48 | .option('-P, --plugin-path [path]', 'look for plugins installed at [path] as well as the default locations ([path] can also point to a single plugin)', path => customPluginPath = path) |
| 49 | .option('-Q, --no-qrcode', 'do not issue QRcode in logging', () => hideQRCode = true) |
| 50 | .option('-K, --keep-orphans', 'keep cached accessories for which the associated plugin is not loaded', () => keepOrphans = true) |
| 51 | .option('-T, --no-timestamp', 'do not issue timestamps in logging', () => noLogTimestamps = true) |
| 52 | .option('-U, --user-storage-path [path]', 'look for homebridge user files at [path] instead of the default location (~/.homebridge)', path => customStoragePath = path) |
| 53 | .option('--strict-plugin-resolution', 'only load plugins from the --plugin-path if set, otherwise from the primary global node_modules', () => strictPluginResolution = true) |
| 54 | .parse(process.argv) |
| 55 | |
| 56 | if (noLogTimestamps) { |
| 57 | Logger.setTimestampEnabled(false) |
| 58 | } |
| 59 | |
| 60 | if (debugModeEnabled) { |
| 61 | Logger.setDebugEnabled(true) |
| 62 | } |
| 63 | |
| 64 | if (forceColourLogging) { |
| 65 | Logger.forceColor() |
| 66 | } |
| 67 | |
| 68 | if (customStoragePath) { |
| 69 | User.setStoragePath(customStoragePath) |
| 70 | } |
| 71 | |
| 72 | // Initialize HAP-NodeJS with a custom persist directory |
| 73 | HAPStorage.setCustomStoragePath(User.persistPath()) |
| 74 | |
| 75 | const options: HomebridgeOptions = { |
| 76 | keepOrphanedCachedAccessories: keepOrphans, |
| 77 | insecureAccess, |
| 78 | hideQRCode, |
| 79 | customPluginPath, |
| 80 | noLogTimestamps, |
| 81 | debugModeEnabled, |
| 82 | forceColourLogging, |
| 83 | customStoragePath, |
| 84 | strictPluginResolution, |
| 85 | } |
nothing calls this directly
no test coverage detected