1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 02:29:26 +02:00

Ported CLI from commander to yargs because yargs suits our large CLI better and is easier to develop with. Split commands into separate files since the file was getting annoyingly long.

This commit is contained in:
Simo Kinnunen 2016-12-21 01:09:08 +09:00
parent 72a16ed2ff
commit cc736ba0ac
35 changed files with 2006 additions and 1538 deletions

View file

@ -145,64 +145,7 @@ doctor.checkADB = function() {
)
}
doctor.checkDevices = function() {
// Show all connected USB devices, including hubs
if (os.platform() === 'darwin') {
childProcess.execFile('ioreg', ['-p', 'IOUSB', '-w0'],
function(error, stdout, stderr) {
log.info('USB devices connected including hubs:')
if (!execHasErrors(error, stderr)) {
var list = stdout.replace(/@.*|\+-o Root\s{2}.*\n|\+-o |^\s{2}/gm, '')
.split('\n')
list.forEach(function(device) {
log.info(device)
})
}
}
)
}
else if (os.platform() === 'linux') {
childProcess.execFile('lsusb', [],
function(error, stdout, stderr) {
log.info('USB devices connected including hubs:')
if (!execHasErrors(error, stderr)) {
var list = stdout.replace(/Bus \d+ Device \d+: ID \w+:\w+ /gm, '')
.split('\n')
list.forEach(function(device) {
log.info(device)
})
}
}
)
}
// Show all the devices seen by adb
childProcess.execFile('adb', ['devices'],
function(error, stdout, stderr) {
log.info('Devices that ADB can see:')
if (!execHasErrors(error, stderr)) {
var s = stdout.replace(/List of devices attached \n|^\s*/gm, '')
if (s.length === 0) {
log.error('No devices')
}
else {
var list = s.split('\n')
list.forEach(function(device) {
log.info(device)
})
}
}
}
)
}
doctor.run = function(options) {
// Check devices
if (options.devices) {
doctor.checkDevices()
return
}
doctor.run = function() {
// Check OS architecture
doctor.checkOSArch()