Something went wrong. Try again.
Your trusty automation assistant in TLE Community misadventures!
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import _ from 'lodash'import Table from 'cli-table3'
import { lacuna, call, log } from '@tlecommunity/super-core'
class ViewLaws { constructor(options) { this.options = options }
validateOptions() { return new Promise((resolve, reject) => { if (!this.options.id) { reject('please specify a station') } else { resolve(true) } }) }
run() { return new Promise((resolve, reject) => { call(() => lacuna.server.callLegacy({ module: 'body', method: 'view_laws', params: [this.options.id], addSession: true, }) ) .then((result) => { if (result.laws.length > 0) { let table = new Table({ head: ['Name', 'Description'], colWidths: [30, 60], })
_.each(result.laws, (law) => { table.push([law.name, law.description]) })
log.newline() log.info(table.toString()) log.newline()
resolve(`Total of ${result.laws.length} laws enacted.`) } else { resolve(`No laws`) } }) .catch(reject) }) }}
export default ViewLaws