-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
executable file
·51 lines (43 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
'use strict'
const sqlite3 = require('sqlite3');
require('colors');
const Stash = require('./lib/stash');
const args = process.argv.slice(2);
const homePath = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
const filePath = homePath + '/stash.db';
const db = new sqlite3.Database(filePath);
const updateNotifier = require('update-notifier');
const pkg = require('./package.json');
updateNotifier({
pkg,
updateCheckInterval: 1000 * 60 * 60 * 24
}).notify();
const options = (type) => {
//Get current pack:
db.get("SELECT pack FROM state limit 1", function (err, row) {
if (err)
console.log(err);
const currpack = row.pack;
const stash = new Stash(db, currpack, args);
const actions = {
'push': 'push',
'p': 'push',
'list': 'list',
'l': 'list',
'get': 'get',
'g': 'get',
'pop': 'pop',
'export': 'export',
'import': 'import',
'pack': 'pack',
'pa': 'pack',
'exec': 'run',
'run': 'run',
'?': 'help',
'default': 'def'
};
return stash[(actions[type] || actions['default'])]();
});
}
options(args[0]);