import {siStationStorageLocations} from 'sportident/lib/SiStation/BaseSiStation'; import {ShellCommandContext} from '../Shell'; import {BaseCommand, ArgType} from './BaseCommand'; import {getDirectOrRemoteStation} from './getDirectOrRemoteStation'; const allInfoNames = ( Object.keys(siStationStorageLocations) as (keyof typeof siStationStorageLocations)[] ); export class GetInfoCommand extends BaseCommand { getArgTypes(): ArgType[] { return [ { name: 'target', choices: ['direct', 'remote'], }, { name: 'information name', choices: Object.keys(siStationStorageLocations), isOptional: true, }, ]; } printUsage(context: ShellCommandContext): void { super.printUsage(context); context.putString('e.g. getInfo direct\n'); context.putString('e.g. getInfo direct code\n'); context.putString('e.g. getInfo remote mode\n'); } run(context: ShellCommandContext): Promise { const device = context.env.device; if (!device) { return Promise.reject(new Error('No device.')); } const station = getDirectOrRemoteStation(context.args[1], device); if (station === undefined) { context.putString('No such station\n'); return Promise.resolve(); } const infoNames = allInfoNames.filter((infoName) => (context.args[2] ? infoName === context.args[2] : true )); return station.readInfo() .then(() => { infoNames.sort(); // logReact(( // // {infoNames.map((infoName) => ( // // // // // // ))} //
{infoName}:{`${station.getInfo(infoName)}`}
// )); infoNames.forEach((infoName) => { context.putString(`${infoName}: ${station.getInfo(infoName)}\n`); }); // selectedMainStation.getTime().then((time1) => { // console.warn(time1 - new Date()); // selectedMainStation.setTime(new Date()).then((time2) => { // console.warn(time2 - new Date()); // }); // }); }); } }