Created
September 9, 2020 15:48
-
-
Save BetterProgramming/571e18cd6ebe83781b6eb209432a3801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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