Skip to content

Commit 8b44cdc

Browse files
authored
Merge pull request #24 from perryrh0dan/dev
Dev
2 parents 416bb16 + 2d314b2 commit 8b44cdc

File tree

15 files changed

+322
-110
lines changed

15 files changed

+322
-110
lines changed

.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"type": "node",
1010
"request": "launch",
1111
"name": "Launch Program",
12-
"program": "${workspaceFolder}/dist/cli.js"
12+
"program": "${workspaceFolder}/dist/cli.js",
13+
"args": ["l", "canceled"]
1314
},
1415
{
1516
"type": "node",

cli.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { UpdateNotifier } from 'update-notifier';
66
// END SNAPCRAFT IGNORE
77

88
import { Taskline } from './src/taskline';
9+
import { Localization } from './src/localization';
910
import logger from './src/utils/logger';
1011
import pkg = require('./package.json');
1112
const taskline = new Taskline();
@@ -20,91 +21,91 @@ program.name('tl').usage('[command] [options]');
2021
program
2122
.command('archive')
2223
.alias('a')
23-
.description('Display archived items')
24+
.description(Localization.instance.get('help.archive'))
2425
.action(() => {
2526
taskline.displayArchive().catch(() => {});
2627
});
2728

2829
program
2930
.command('begin <ids>')
3031
.alias('b')
31-
.description('Start/pause task')
32+
.description(Localization.instance.get('help.begin'))
3233
.action(ids => {
3334
taskline.beginTasks(ids).catch(() => {});
3435
});
3536

3637
program
3738
.command('cancel <ids>')
38-
.description('Cancel/revive task')
39+
.description(Localization.instance.get('help.cancel'))
3940
.action(ids => {
4041
taskline.cancelTasks(ids).catch(() => {});
4142
});
4243

4344
program
4445
.command('check <ids>')
4546
.alias('c')
46-
.description('Check/uncheck task')
47+
.description(Localization.instance.get('help.check'))
4748
.action(ids => {
4849
taskline.checkTasks(ids).catch(() => {});
4950
});
5051

5152
program
5253
.command('clear')
53-
.description('Delete all checked items')
54+
.description(Localization.instance.get('help.clear'))
5455
.action(() => {
5556
taskline.clear().catch(() => {});
5657
});
5758

5859
program
5960
.command('config')
60-
.description('Display active config')
61+
.description(Localization.instance.get('help.config'))
6162
.action(() => {
6263
taskline.displayConfig();
6364
});
6465

6566
program
6667
.command('copy <ids>')
6768
.alias('y')
68-
.description('Copy description to clipboard')
69+
.description(Localization.instance.get('help.copy'))
6970
.action(ids => {
7071
taskline.copyToClipboard(ids).catch(() => {});
7172
});
7273

7374
program
7475
.command('delete <ids>')
7576
.alias('d')
76-
.description('Delete item')
77+
.description(Localization.instance.get('help.delete'))
7778
.action(ids => {
7879
taskline.deleteItems(ids).catch(() => {});
7980
});
8081

8182
program
8283
.command('due <ids> <dueDate>')
83-
.description('Update duedateof task')
84+
.description(Localization.instance.get('help.due'))
8485
.action((ids, dueDate) => {
8586
taskline.updateDueDate(ids, dueDate).catch(() => {});
8687
});
8788

8889
program
8990
.command('edit <id> <description>')
9091
.alias('e')
91-
.description('Edit item description')
92+
.description(Localization.instance.get('help.edit'))
9293
.action((id, description) => {
9394
taskline.editDescription(id, description).catch(() => {});
9495
});
9596

9697
program
9798
.command('find <terms>')
9899
.alias('f')
99-
.description('Search for items')
100+
.description(Localization.instance.get('help.find'))
100101
.action(query => {
101102
taskline.findItems(query).catch(() => {});
102103
});
103104

104105
program
105106
.command('list <terms>')
106107
.alias('l')
107-
.description('List items by attributes')
108+
.description(Localization.instance.get('help.list'))
108109
.action(terms => {
109110
taskline.listByAttributes(terms).then(grouped => {
110111
taskline.displayStats(grouped);
@@ -114,15 +115,15 @@ program
114115
program
115116
.command('move <ids> <boards')
116117
.alias('m')
117-
.description('Move item between boards')
118+
.description(Localization.instance.get('help.move'))
118119
.action((ids, boards) => {
119120
taskline.moveBoards(ids, boards).catch(() => {});
120121
});
121122

122123
program
123124
.command('note <description>')
124125
.alias('n')
125-
.description('Create note')
126+
.description(Localization.instance.get('help.note'))
126127
.option('-b, --board <board>', 'Board')
127128
.action((description, opts) => {
128129
taskline.createNote(description, opts.board).catch(() => {});
@@ -131,7 +132,7 @@ program
131132
program
132133
.command('priority <id> <priority>')
133134
.alias('p')
134-
.description('Update priority of task')
135+
.description(Localization.instance.get('help.priority'))
135136
.action((id, priority) => {
136137
taskline.updatePriority(id, priority).catch(() => {});
137138
});
@@ -140,23 +141,23 @@ program
140141
.command('restore <ids>')
141142

142143
.alias('r')
143-
.description('Restore items from archive')
144+
.description(Localization.instance.get('help.restore'))
144145
.action(ids => {
145146
taskline.restoreItems(ids).catch(() => {});
146147
});
147148

148149
program
149150
.command('star <ids>')
150151
.alias('s')
151-
.description('Star/unstar item')
152+
.description(Localization.instance.get('help.star'))
152153
.action(ids => {
153154
taskline.starItems(ids).catch(() => {});
154155
});
155156

156157
program
157158
.command('task <description>') // Sub-command name
158159
.alias('t') // Alternative sub-command is `al`
159-
.description('Create task') // Command description
160+
.description(Localization.instance.get('help.task')) // Command description
160161
.option('-b, --board <board>', 'Board')
161162
.option('-p, --priority <priority>', 'Priority')
162163
.option('-d, --due <date>', 'Due date')
@@ -171,7 +172,7 @@ program
171172
program
172173
.command('timeline')
173174
.alias('i')
174-
.description('Display timeline view')
175+
.description(Localization.instance.get('help.timeline'))
175176
.action(() => {
176177
taskline.displayByDate().then(grouped => {
177178
taskline.displayStats(grouped);
@@ -180,7 +181,7 @@ program
180181

181182
program
182183
.command('refactor')
183-
.description('Rearrange the IDs of all items')
184+
.description(Localization.instance.get('help.refactor'))
184185
.action(() => {
185186
taskline.refactorIDs().catch(() => {});
186187
});
@@ -197,7 +198,7 @@ if (process.argv.length === 2) {
197198
}
198199

199200
program.on('command:*', function() {
200-
console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
201+
console.error(Localization.instance.getf('errors.invalidCommand', { params: program.args }));
201202
process.exit(1);
202203
});
203204

i18n/de.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
{
2-
"help": "Tippe `tl --help` um anzufangen!",
2+
"help": {
3+
"default": "Benutze `--help` um anzufangen.",
4+
"archive": "Archivierte Items anzeigen",
5+
"begin": "Aufgabe starten/pausieren",
6+
"cancel": "Aufgabe abbrechen/wiederaufnehmen",
7+
"check": "Aufgabe abhaken/unabhaken",
8+
"clear": "Alle abgeschlossenen Aufgaben archivieren",
9+
"config": "Konfiguration anzeigen",
10+
"copy": "Item in die Zwischenablage kopieren",
11+
"delete": "Item löschen",
12+
"due": "Fälligkeitsdatum ändern",
13+
"edit": "Itembeschreibung ändern",
14+
"find": "Nach Items suchen",
15+
"list": "List items by attributes",
16+
"move": "Items zwischen Tafeln verschieben",
17+
"note": "Notiz erstellen",
18+
"priority": "Priorität von Aufgabe/n updaten",
19+
"restore": "Items wiederherstellen",
20+
"star": "Item mit Stern markieren/unmarkieren",
21+
"task": "Aufgabe erstellen",
22+
"timeline": "Zeitleistenansicht",
23+
"refactor": "ID Bereich aller Items zurücksetzen",
24+
"footer": "Detaillierte Beschreibung auf: https://github.com/perryrh0dan/taskline#flight-manual"
25+
},
326
"config": {
427
"path": "Konfiguration geladen aus {0}",
528
"title": "Konfiguration"
@@ -28,7 +51,7 @@
2851
}
2952
},
3053
"errors": {
31-
54+
"invalidCommand": "Ungültiger Befehl: {0}\nÖffne --help für eine detaillierte Liste aller Befehle."
3255
},
3356
"stats": {
3457
"allDone": "Alles erledigt!",

i18n/en.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
{
2-
"help": "Type `tl --help` to get started!",
2+
"help": {
3+
"default": "Type `tl --help` to get started!",
4+
"archive": "Display archived items",
5+
"begin": "Start/pause task",
6+
"cancel": "Cancel/revive task",
7+
"check": "Check/uncheck task",
8+
"clear": "Delete all checked items",
9+
"config": "Display active config",
10+
"copy": "Copy description to clipboard",
11+
"delete": "Delete item",
12+
"due": "Update duedate of task",
13+
"edit": "Edit item description",
14+
"find": "Search for items",
15+
"list": "List items by attributes",
16+
"move": "Move item between boards",
17+
"note": "Create note",
18+
"priority": "Update priority of task",
19+
"restore": "Restore items from archive",
20+
"star": "Star/unstar item",
21+
"task": "Create task",
22+
"timeline": "Display timeline view",
23+
"refactor": "Rearrange the IDs of all items",
24+
"footer": "Detailed description under: https://github.com/perryrh0dan/taskline#flight-manual"
25+
},
326
"config": {
427
"path": "Config loaded from {0}",
528
"title": "Configuration"
@@ -28,7 +51,7 @@
2851
}
2952
},
3053
"errors": {
31-
54+
"invalidCommand": "Invalid command: {0}\nSee --help for a list of available commands."
3255
},
3356
"stats": {
3457
"allDone": "All done!",

i18n/es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"help": "Escriba `tl --help` para comenzar.",
2+
"help": {
3+
"default": "Escriba `tl --help` para comenzar."
4+
},
35
"config": {
46
"path": "Configuracion cargada de {0}",
57
"title": "Configuracion"

src/item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const now: Date = new Date();
2-
31
export interface ItemProperties {
42
id: number;
53
date?: string;
@@ -19,6 +17,8 @@ export abstract class Item {
1917
protected _boards: Array<string>;
2018

2119
public constructor(kwArgs: ItemProperties) {
20+
const now: Date = new Date();
21+
2222
this.id = kwArgs.id;
2323
this.date = kwArgs.date || now.toDateString();
2424
this.timestamp = kwArgs.timestamp || now.getTime();

src/libs/date.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,8 @@ export const getRelativeHumanizedDate = function(dueDate: Date, now?: Date): str
194194
}
195195

196196
const absValue = Math.abs(value);
197-
debugger;
198197
unit = Localization.instance.get('date.units.' + unit, { type: absValue === 1 ? 0 : 1 });
199198
const humanizedDate = value >= 1 ? `${value} ${unit}` : `${absValue} ${unit}`;
200-
debugger;
201199
const humanizedRelativeDate = value >= 1 ? Localization.instance.getf('date.due_in', { params: [humanizedDate] }) : Localization.instance.getf('date.due_ago', { params: [humanizedDate] });
202200
return humanizedRelativeDate;
203201
};

src/localization.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class Localization {
3636
}
3737
this.default = this.load('en');
3838
} catch (error) {
39-
debugger;
4039
Renderer.instance.invalidLanguageFile();
4140
process.exit(1);
4241
}

src/renderer.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ export class Renderer {
191191
return this.printColor('pale', text);
192192
}
193193

194+
private getPassedTime(passedTime: number): string {
195+
const seconds = passedTime / 1000;
196+
const minutes = Math.floor((seconds / 60) % 60);
197+
const hours = Math.floor(seconds / 3600);
198+
199+
return `${hours + Math.round(minutes/60 * 100) / 100} hours`;
200+
}
201+
194202
private getCorrelation(items: Array<Item>): string {
195203
const { tasks, complete } = this.getItemStats(items);
196204
return this.printColor('pale', `[${complete}/${tasks}]`);
@@ -305,6 +313,11 @@ export class Renderer {
305313
dueDate = this.getDueDate(item.dueDate);
306314
}
307315

316+
let passedTime;
317+
if (item instanceof Task && item.passedTime > 0) {
318+
passedTime = this.getPassedTime(item.passedTime);
319+
}
320+
308321
const star = this.getStar(item);
309322

310323
const prefix = this.buildPrefix(item);
@@ -316,6 +329,12 @@ export class Renderer {
316329
suffix = age.length === 0 ? star : `${age} ${star}`;
317330
}
318331

332+
if (passedTime) {
333+
suffix += ` (${passedTime})`;
334+
}
335+
336+
suffix = suffix.replace(' ', ' ');
337+
319338
const msgObj = {
320339
prefix,
321340
message,
@@ -428,12 +447,8 @@ export class Renderer {
428447
});
429448
}
430449

431-
if (pending + inProgress + complete + notes === 0) {
432-
this.signale.log({
433-
prefix: '\n ',
434-
message: Localization.instance.get('help'),
435-
suffix: this.printColor('icons.star', '★')
436-
});
450+
if (pending + inProgress + canceled + complete + notes === 0) {
451+
return console.log(Localization.instance.get('help.default'));
437452
}
438453

439454
this.signale.log({

0 commit comments

Comments
 (0)