Skip to content

Commit f412bee

Browse files
committed
Show 'favor' icon of problem.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 20b7fd1 commit f412bee

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function setLogLevel() {
2424

2525
log.setLevel(level);
2626

27-
log.fail = function(msg) {
28-
log.error(chalk.red('ERROR: ' + msg));
27+
log.fail = function(e) {
28+
log.error(chalk.red('ERROR: ' + (e.msg || e)));
2929
};
3030
}
3131

lib/commands/list.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var _ = require('underscore');
2+
var chalk = require('chalk');
23
var sprintf = require('sprintf-js').sprintf;
34
var log = require('loglevel');
45

@@ -80,9 +81,10 @@ cmd.handler = function(argv) {
8081
stat[problem.state] = (stat[problem.state] || 0) + 1;
8182
if (problem.locked) ++stat.locked;
8283

83-
log.info(sprintf('%s %s [%3d] %-60s %-6s (%.2f %%)',
84-
h.prettyState(problem.state),
84+
log.info(sprintf('%s %s %s [%3d] %-60s %-6s (%.2f %%)',
85+
(problem.favor ? chalk.yellow('★') : ' '),
8586
(problem.locked ? '🔒' : ' '),
87+
h.prettyState(problem.state),
8688
problem.id,
8789
problem.name,
8890
problem.level,

lib/leetcode_client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ leetcodeClient.getProblems = function(cb) {
9999
link: config.URL_PROBLEM.replace('$id', p.stat.question__title_slug),
100100
locked: p.paid_only,
101101
percent: p.stat.total_acs * 100 / p.stat.total_submitted,
102-
level: h.levelToName(p.difficulty.level)
102+
level: h.levelToName(p.difficulty.level),
103+
favor: p.is_favor
103104
};
104105
});
105106

0 commit comments

Comments
 (0)