Skip to content

Instantly share code, notes, and snippets.

@SomeHats
Created August 10, 2018 11:07
Show Gist options
  • Save SomeHats/5aed93d910db63079962005be2ccd7da to your computer and use it in GitHub Desktop.
Save SomeHats/5aed93d910db63079962005be2ccd7da to your computer and use it in GitHub Desktop.
did - track stuff wat u did
#!/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)}`);
}
);
{
"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