Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add category #53

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
module.exports = {
"env": {
"browser": false,
"es6": true,
"mocha": true,
"node": true
},
"extends": [
"google",
"eslint:recommended"
],
"rules": {
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"camelcase": [2, {properties: "never"}],
"comma-dangle": 0,
"curly": 0,
"key-spacing": [2, {align: "value"}],
"max-len": [1, 120],
"no-control-regex": 0,
"no-console": 1,
"no-empty": [2, { "allowEmptyCatch": true }],
"no-eval": 1, // we use it on purpose
"no-loop-func": 1,
"no-multi-spaces": 0,
"no-proto": 1,
"no-unused-expressions": 1,
"no-unused-vars": 1,
"no-var": 0,
"no-warning-comments": 0,
"prefer-rest-params": 0,
"prefer-spread": 0,
"quote-props": 1,
"quotes": [2, "single", {avoidEscape: true}],
"require-jsdoc": 0,
}
'env': {
'browser': false,
'es6': true,
'mocha': true,
'node': true
},
'extends': [
'google',
'eslint:recommended'
],
'rules': {
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {'allowSingleLine': true}],
'camelcase': [2, {properties: 'never'}],
'comma-dangle': 0,
'curly': 0,
'key-spacing': [2, {align: 'value'}],
'max-len': [1, 120],
'no-control-regex': 0,
'no-console': 1,
'no-empty': [2, {'allowEmptyCatch': true}],
'no-eval': 1, // we use it on purpose
'no-loop-func': 1,
'no-multi-spaces': 0,
'no-proto': 1,
'no-unused-expressions': 1,
'no-unused-vars': 1,
'no-var': 0,
'no-warning-comments': 0,
'prefer-rest-params': 0,
'prefer-spread': 0,
'quote-props': 1,
'quotes': [2, 'single', {avoidEscape: true}],
'require-jsdoc': 0,
}
};
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ dist/
tmp/
*.swp
.DS_Store
.idea
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/leetcode-cli.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions lib/chalk.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
var _ = require('underscore');
var style = require('ansi-styles');
var supportsColor = require('supports-color');
const _ = require('underscore');
const style = require('ansi-styles');
const supportsColor = require('supports-color');

var file = require('./file');
const file = require('./file');

const chalk = {
enabled: supportsColor.stdout,
Expand Down Expand Up @@ -68,8 +68,8 @@ chalk.init = function() {
theme[k] = style.color.ansi16m.hex(v);
theme[bgK] = style.bgColor.ansi16m.hex(v);
} else if (chalk.use256) {
theme[k] = style.color.ansi256.hex(v);
theme[bgK] = style.bgColor.ansi256.hex(v);
theme[k] = style.color.ansi256(style.hexToAnsi256(v));
theme[bgK] = style.bgColor.ansi256(style.hexToAnsi256(v));
} else {
theme[k] = style.color.ansi.hex(v);
theme[bgK] = style.bgColor.ansi.hex(v);
Expand Down
20 changes: 10 additions & 10 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ function initLogLevel() {

function initDir() {
file.init();
file.mkdir(file.homeDir())
file.mkdir(file.homeDir());
}

function initPlugins(cb) {
if (Plugin.init()) {
Plugin.save();
return cb();
} else {
Plugin.installMissings(function(e) {
Plugin.installMissing(function(e) {
if (e) return cb(e);
Plugin.init();
return cb();
Expand All @@ -77,13 +77,13 @@ function runCommand() {
var yargs = require('yargs');
h.width = yargs.terminalWidth();
yargs.commandDir('commands')
.completion()
.help('h')
.alias('h', 'help')
.version(false)
.epilog('Seek more help at https://skygragon.github.io/leetcode-cli/commands')
.wrap(Math.min(h.width, 120))
.argv;
.completion()
.help('h')
.alias('h', 'help')
.version(false)
.epilog('Seek more help at https://skygragon.github.io/leetcode-cli/commands')
.wrap(Math.min(h.width, 120))
.argv;
}

cli.run = function() {
Expand All @@ -96,7 +96,7 @@ cli.run = function() {
initColor();
initIcon();
initLogLevel();
initDir()
initDir();
initPlugins(function(e) {
if (e) return log.fatal(e);
cache.init();
Expand Down
16 changes: 9 additions & 7 deletions lib/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const cmd = {
default: false,
describe: 'Set to true to disable endpoint\'s translation',
})
.option('c', core.filters.category)
.positional('keyword', {
type: 'string',
default: '',
Expand All @@ -45,7 +46,8 @@ const cmd = {
.example(chalk.yellow('leetcode list array'), 'List questions that has "array" in name')
.example(chalk.yellow('leetcode list -q eD'), 'List questions that with easy level and not done')
.example(chalk.yellow('leetcode list -t google'), 'List questions from Google company (require plugin)')
.example(chalk.yellow('leetcode list -t stack'), 'List questions realted to stack (require plugin)');
.example(chalk.yellow('leetcode list -t stack'), 'List questions realted to stack (require plugin)')
.example(chalk.yellow('leetcode list -c lcof'), 'List questions from category (require plugin)');
}
};

Expand All @@ -59,14 +61,14 @@ cmd.handler = function(argv) {
if (word.endsWith(word.substr(-1).repeat(6))) {
log.warn('Hmmm...you might need a new keyboard?');
}
problems = problems.filter(x => x.name.toLowerCase().includes(word));
problems = problems.filter((x) => x.name.toLowerCase().includes(word));
}

const stat = {};
for (let x of ['locked', 'starred', 'ac', 'notac', 'None', 'Easy', 'Medium', 'Hard']) stat[x] = 0;
for (const x of ['locked', 'starred', 'ac', 'notac', 'None', 'Easy', 'Medium', 'Hard']) stat[x] = 0;

problems = _.sortBy(problems, x => -x.fid);
for (let problem of problems) {
problems = _.sortBy(problems, (x) => x.id);
for (const problem of problems) {
stat[problem.level] = (stat[problem.level] || 0) + 1;
stat[problem.state] = (stat[problem.state] || 0) + 1;
if (problem.locked) ++stat.locked;
Expand All @@ -76,7 +78,7 @@ cmd.handler = function(argv) {
(problem.starred ? chalk.yellow(icon.like) : icon.empty),
(problem.locked ? chalk.red(icon.lock) : icon.nolock),
h.prettyState(problem.state),
problem.fid,
problem.id,
problem.name,
h.prettyLevel(problem.level),
(problem.percent || 0).toFixed(2));
Expand All @@ -88,7 +90,7 @@ cmd.handler = function(argv) {

let buf = [];
let len = 0;
for (let x of badges) {
for (const x of badges) {
if (len + x.length + 3 >= 60) {
log.printf('%12s%s', ' ', chalk.gray(buf.join(' | ')));
buf = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ cmd.handler = function(argv) {
if (name) {
Plugin.install(name, cb);
} else {
Plugin.installMissings(cb);
Plugin.installMissing(cb);
}
return;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const DEFAULT_CONFIG = {
'algorithms',
'database',
'shell',
'concurrency'
'concurrency',
'lcci',
'lcof',
],
langs: [
'bash',
Expand Down Expand Up @@ -75,8 +77,8 @@ const DEFAULT_CONFIG = {
lang: 'cpp'
},
file: {
show: '${fid}.${slug}',
submission: '${fid}.${slug}.${sid}.${ac}'
show: '${id}.${slug}',
submission: '${id}.${slug}.${sid}.${ac}'
},
color: {
enable: true,
Expand Down
Loading