Created
August 10, 2018 11:07
-
-
Save SomeHats/5aed93d910db63079962005be2ccd7da to your computer and use it in GitHub Desktop.
did - track stuff wat u did
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
#!/usr/bin/env node | |
const fs = require("fs"); | |
const path = require("path"); | |
const os = require("os"); | |
const Airtable = require("airtable"); | |
const apiKeyFile = path.join(os.homedir(), ".done-airtable-api-key"); | |
const apiKey = fs.readFileSync(apiKeyFile, "utf-8").trim(); | |
const baseIdFile = path.join(os.homedir(), ".done-base-id"); | |
const baseId = fs.readFileSync(baseIdFile, "utf-8").trim(); | |
const base = new Airtable({ apiKey }).base(baseId); | |
const args = process.argv.slice(2).filter(arg => arg != null); | |
if (args.length !== 1) { | |
console.log("Usage: did 'a thing you did'"); | |
process.exit(1); | |
} | |
const emoji = ["π", "π", "π", "π―", "π", "π", "β¨"]; | |
const responses = [ | |
"nice", | |
"well done", | |
"you're just too good at this", | |
"yessss", | |
"incredible!", | |
"awesome", | |
"how are you so cool?" | |
]; | |
const sample = arr => arr[Math.floor(Math.random() * arr.length)]; | |
base("Done").create( | |
{ | |
Name: args[0].trim() | |
}, | |
(err, record) => { | |
if (err) { | |
console.log(err); | |
process.exit(1); | |
} | |
console.log(`${sample(emoji)} ${sample(responses)}`); | |
} | |
); |
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
{ | |
"name": "did", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"airtable": "^0.5.6" | |
}, | |
"bin": { | |
"did": "./index.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment