MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / builder

Function builder

src/commands/edge/drivers/logcat.ts:50–91  ·  view source on GitHub ↗
(yargs: Argv)

Source from the content-addressed store, hash-verified

48const describe = 'stream logs from installed drivers, simple temporary hard-coded version'
49
50const builder = (yargs: Argv): Argv<CommandArgs> =>
51 apiCommandBuilder(yargs)
52 .positional('driver-id', { describe: 'a specific driver to stream logs from', type: 'string' })
53 .option('all', { alias: 'a', describe: 'stream from all installed drivers', type: 'boolean' })
54 .option(
55 'hub-address',
56 { describe: 'IPv4 address of hub with optionally appended port number', type: 'string' },
57 )
58 .option(
59 'connect-timeout',
60 {
61 describe: 'max time allowed when connecting to hub in milliseconds',
62 type: 'number',
63 default: defaultLiveLogTimeout,
64 },
65 )
66 .option(
67 'log-level',
68 {
69 describe: 'minimum level of event to log',
70 type: 'string',
71 default: 'trace',
72 choices: Object.keys(logLevels),
73 coerce: arg => {
74 const logLevel = arg ? arg.toLowerCase() : 'trace'
75 if ((logLevel in logLevels)) {
76 return logLevel
77 }
78 console.warn(`${arg} is not a valid log-level. Logging all events.`)
79 return 'trace'
80 },
81 },
82 )
83 .example([
84 ['$0 edge:drivers:logcat', 'choose hub and driver from prompts'],
85 ['$0 edge:drivers:logcat --log-level WARN', 'log only at WARN level and above'],
86 [
87 '$0 edge:drivers:logcat --all --hub-address 192.168.1.13',
88 'log for all drivers on hub with IP address 192.168.1.13',
89 ],
90 ])
91 .epilog(buildEpilog({ command }))
92
93const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
94 const command = await apiCommand(argv)

Callers

nothing calls this directly

Calls 2

apiCommandBuilderFunction · 0.85
buildEpilogFunction · 0.85

Tested by

no test coverage detected