-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
executable file
·60 lines (50 loc) · 1.83 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
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
require('dotenv').config()
const program = require('commander')
const figlet = require('figlet')
const inquirer = require('inquirer')
const chalk = require('chalk')
const { startActivity } = require('./commands/startActivity')
const { generateReport } = require('./commands/generateReport')
const { getCLIVersion } = require('./helpers/get-cli-version')
const { stopActivity } = require('./commands/stopActivity.js')
inquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'))
inquirer.registerPrompt('datepicker', require('inquirer-datepicker'))
initCli()
async function initCli () {
const version = await getCLIVersion()
program
.version(version, '-v, --version')
program
.command('track [activityName]')
.description('start tracking for a specific activity, stops current tracking before starting a new one')
// .option('-s, --setup_mode [mode]', 'Which setup mode to use')
.action(async (activityName, options) => {
await startActivity(activityName, options)
})
program
.command('report')
.description('generates timeular report in csv or xlsx format')
.option('-s, --startTime <startTime>', 'startTime')
.option('-e, --endTime <endTime>', 'endTime')
.option('-f, --format <format>', 'xlsx or csv')
.action(async options => {
await generateReport(options)
})
program
.command('stop')
.description('stops tracking current activity')
.action(async (activityName, options) => {
await stopActivity(activityName, options)
})
console.log(chalk.magenta(figlet.textSync('Timeular', {
// font: 'Dancing Font',
horizontalLayout: 'full',
verticalLayout: 'full'
})))
program.parse(process.argv)
// if no commands/arguments specified, show the help
if (!process.argv.slice(2).length) {
program.help()
}
}