Support multiple arguments to sync multiple days
parent
f1cc532f3d
commit
f7ecf95074
26
src/index.ts
26
src/index.ts
|
@ -99,24 +99,28 @@ async function apply_tasks_for_range(workspace: Workspace, interval: Interval, w
|
||||||
|
|
||||||
void (async function () {
|
void (async function () {
|
||||||
const config = await inferConfig()
|
const config = await inferConfig()
|
||||||
const interval = dateToInterval(process.argv.length > 2 ? process.argv[2] : 'today')
|
const args = process.argv.length > 2 ? process.argv.slice(2) : ["today"]
|
||||||
|
|
||||||
|
|
||||||
const marvin = new Marvin(Marvin.parseCredentials(config.marvin), config.marvinDB + "marvin")
|
const marvin = new Marvin(Marvin.parseCredentials(config.marvin), config.marvinDB + "marvin")
|
||||||
const tasks = await (marvin.root.category('Datakami').then(datakami => datakami.tasksOverlapping(interval)))
|
|
||||||
|
|
||||||
const toggl = new Toggl(config.toggl)
|
const toggl = new Toggl(config.toggl)
|
||||||
const workspaces = await toggl.workspaces()
|
const workspaces = await toggl.workspaces()
|
||||||
if (workspaces.length !== 1) throw new Error("not sure which workspace to use")
|
if (workspaces.length !== 1) throw new Error("not sure which workspace to use")
|
||||||
|
for (const arg of args) {
|
||||||
|
const interval = dateToInterval(arg)
|
||||||
|
const tasks = await (marvin.root.category('Datakami').then(datakami => datakami.tasksOverlapping(interval)))
|
||||||
|
|
||||||
const res_tasks: TogglTE[] = []
|
const res_tasks: TogglTE[] = []
|
||||||
for (const task of tasks)
|
for (const task of tasks)
|
||||||
for (const task_interval of task.timesInInterval(interval))
|
for (const task_interval of task.timesInInterval(interval))
|
||||||
res_tasks.push({
|
res_tasks.push({
|
||||||
description: `${task.title}`,
|
description: `${task.title}`,
|
||||||
start: toRFC3339(task_interval.start),
|
start: toRFC3339(task_interval.start),
|
||||||
stop: toRFC3339(task_interval.end)
|
stop: toRFC3339(task_interval.end)
|
||||||
})
|
})
|
||||||
|
|
||||||
await apply_tasks_for_range(workspaces[0], interval, res_tasks)
|
await apply_tasks_for_range(workspaces[0], interval, res_tasks)
|
||||||
|
}
|
||||||
|
|
||||||
})()
|
})()
|
||||||
|
|
Loading…
Reference in New Issue