Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created September 9, 2020 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/571e18cd6ebe83781b6eb209432a3801 to your computer and use it in GitHub Desktop.
Save BetterProgramming/571e18cd6ebe83781b6eb209432a3801 to your computer and use it in GitHub Desktop.
const {Command, flags} = require('@oclif/command')
const Weight = require('../api/weight')
const weight = new Weight()
class ShowCommand extends Command {
async run() {
const {flags} = this.parse(ShowCommand)
const count = flags.count
const records = weight.show(parseInt(count))
for (let i =records.length -1 ; i >= 0; i--){
let record = records[i]
this.log(` Date: ${record.date}, Weight: ${record.weight}`)
}
}
}
ShowCommand.description = "show past weight records"
ShowCommand.flags = {
count: flags.string({char: 'c', description: 'count of past records to be displayed'}),
help: flags.help({char: 'h'})
}
module.exports = ShowCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment