-## Showcases
+A productive cli tool to enjoy leetcode!
-`help`/`user`/`list`/`show`/`test`
+Great thanks to leetcode.com, a really awesome website!
+
+⦙ [Releases](https://skygragon.github.io/leetcode-cli/releases) ⦙
+[Install](https://skygragon.github.io/leetcode-cli/install) ⦙
+[Docs](https://skygragon.github.io/leetcode-cli/) ⦙
+[Commands](https://skygragon.github.io/leetcode-cli/commands) ⦙
+[Advanced](https://skygragon.github.io/leetcode-cli/advanced) ⦙
+[Plugins](https://github.com/skygragon/leetcode-cli-plugins) ⦙
-
+* A very [**EFFICIENT**](#quick-start) way to fight questions.
+* [**CACHING**](https://skygragon.github.io/leetcode-cli/advanced#cache) questions to ease offline thinking.
+* [**GENERATING**](https://skygragon.github.io/leetcode-cli/commands#show) source code before coding.
+* Live [**TEST**](https://skygragon.github.io/leetcode-cli/commands#test) and [**SUBMIT**](https://skygragon.github.io/leetcode-cli/commands#submit) with leetcode.com.
+* Download your previous [**SUBMISSION**](https://skygragon.github.io/leetcode-cli/commands#submission).
+* Trace your coding [**STATUS**](https://skygragon.github.io/leetcode-cli/commands#stat).
+* [**AUTO LOGIN**](https://skygragon.github.io/leetcode-cli/advanced#auto-login) among multiple agents with single account.
+* Multiple [**THEMES**](https://skygragon.github.io/leetcode-cli/advanced#color-themes) support.
+* More [**PLUGINS**](https://skygragon.github.io/leetcode-cli/advanced#plugins) to enjoy extra features!
-`test`/`submit`/`stat`/`submission`
+## Screenshot
-
+
## Quick Start
Read help first $ leetcode help
Login with your leetcode account $ leetcode user -l
- Browse all problems $ leetcode list
- Choose one problem $ leetcode show 1 -g -l cpp
+ Browse all questions $ leetcode list
+ Choose one question $ leetcode show 1 -g -l cpp
Coding it!
Run test(s) and pray... $ leetcode test ./two-sum.cpp -t '[3,2,4]\n7'
Submit final solution! $ leetcode submit ./two-sum.cpp
diff --git a/bin/entrypoint b/bin/entrypoint
new file mode 100755
index 00000000..c2ebd337
--- /dev/null
+++ b/bin/entrypoint
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+srcdir=/root/leetcode-cli
+leetcode=$srcdir/bin/leetcode
+
+if [ ! -f "$leetcode" ]; then
+ echo "Unpacking leetcode-cli code ..."
+ mkdir -p $srcdir
+ tar zxf /leetcode-cli.tar.gz -C $srcdir
+fi
+
+export TERM=xterm-256color
+exec $leetcode $@
diff --git a/bin/install b/bin/install
index be1cd3ae..6f39955a 100755
--- a/bin/install
+++ b/bin/install
@@ -32,8 +32,5 @@ check npm
create $ENVFILE
-npm install
-echo "You might need root privilege to install globally ... "
-sudo npm install -g .
-
+npm install -g .
echo "leetcode-cli successfully installed."
diff --git a/bin/pkg b/bin/pkg
new file mode 100755
index 00000000..0cc22db1
--- /dev/null
+++ b/bin/pkg
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+const arch = require('os').arch();
+var os = process.platform;
+const ver = process.versions.node.split('.')[0];
+
+var bin = './bin/pkg.sh';
+var args = [arch, os, ver];
+
+if (os === 'darwin') {
+ args[1] = 'macos';
+} else if (os === 'win32') {
+ bin = 'cmd.exe';
+ args = ['/c', 'bin\\pkg.bat'].concat(args);
+}
+
+var proc = require('child_process').spawn(bin, args);
+proc.stdout.on('data', x => console.log(x.toString().trimRight('\n')));
+proc.stderr.on('data', x => console.log(x.toString().trimRight('\n')));
+proc.on('close', process.exit);
\ No newline at end of file
diff --git a/bin/pkg.bat b/bin/pkg.bat
new file mode 100644
index 00000000..0294b7f5
--- /dev/null
+++ b/bin/pkg.bat
@@ -0,0 +1,25 @@
+@echo off
+set arch=%1
+set os=%2
+set ver=%3
+
+set dist=dist\
+set file=leetcode-cli.node%ver%.%os%.%arch%.zip
+
+mkdir %dist%
+del /q %dist%\*
+del /q *.zip
+
+for %%x in (company cookie.chrome cookie.firefox cpp.lint cpp.run github leetcode.cn lintcode solution.discuss) do (
+ echo [%%x]
+ node bin\leetcode ext -i %%x
+ if %ERRORLEVEL% gtr 0 exit /b 1
+)
+
+for /r . %%x in (*.node) do copy %%x %dist%
+call npm run pkg -- node%ver%-%os%-%arch%
+if %ERRORLEVEL% gtr 0 exit /b 1
+
+7z a %file% %dist%
+if %ERRORLEVEL% gtr 0 exit /b 1
+exit 0
\ No newline at end of file
diff --git a/bin/pkg.sh b/bin/pkg.sh
new file mode 100755
index 00000000..abeb778d
--- /dev/null
+++ b/bin/pkg.sh
@@ -0,0 +1,26 @@
+#!/bin/bash -e
+
+arch=$1
+os=$2
+ver=$3
+
+DIST=./dist
+FILE=leetcode-cli.node$ver.$os.$arch.tar.gz
+
+mkdir -p $DIST
+rm -rf $DIST/*
+rm -rf $FILE
+
+plugins="company cookie.chrome cookie.firefox cpp.lint cpp.run github leetcode.cn lintcode solution.discuss"
+
+for plugin in $plugins; do
+ echo "[$plugin]"
+ ./bin/leetcode ext -i $plugin
+done
+
+find node_modules -name "*.node" -exec cp {} $DIST \;
+npm run pkg -- node$ver-$os-$arch
+
+tar zcvf $FILE $DIST
+ls -al $FILE
+exit 0
\ No newline at end of file
diff --git a/colors/blue.json b/colors/blue.json
index 76b7eac0..7577d79d 100644
--- a/colors/blue.json
+++ b/colors/blue.json
@@ -1,6 +1,10 @@
{
- "gray": "#B0C4DE",
- "green": "#66D9EF",
- "red": "#AE81FF",
- "yellow": "#87CEEB"
+ "blue": "#0000ff",
+ "cyan": "#b0c4de",
+ "gray": "#483d8b",
+ "green": "#00bfff",
+ "magenta": "#6a5acd",
+ "red": "#ae81ff",
+ "white": "#f0f8ff",
+ "yellow": "#87cefa"
}
diff --git a/colors/dark.json b/colors/dark.json
index c7b90db3..86e60471 100644
--- a/colors/dark.json
+++ b/colors/dark.json
@@ -1,6 +1,9 @@
{
+ "blue": "#000099",
+ "cyan": "#009999",
"gray": "#455354",
"green": "#009900",
+ "magenta": "#990099",
"red": "#990000",
"yellow": "#999900"
}
diff --git a/colors/molokai.json b/colors/molokai.json
new file mode 100644
index 00000000..1e75d1ea
--- /dev/null
+++ b/colors/molokai.json
@@ -0,0 +1,10 @@
+{
+ "blue": "#66D9EF",
+ "cyan": "#AE81FF",
+ "gray": "#75715E",
+ "green": "#87FF00",
+ "magenta": "#FF46FF",
+ "red": "#D7005F",
+ "white": "#F8F8F2",
+ "yellow": "#FD971F"
+}
diff --git a/colors/orange.json b/colors/orange.json
index ac68279b..2fcc4378 100644
--- a/colors/orange.json
+++ b/colors/orange.json
@@ -1,6 +1,10 @@
{
- "gray": "#C4BE89",
- "green": "#E6DB74",
- "red": "#ef5939",
- "yellow": "#FD971F"
+ "blue": "#808000",
+ "cyan": "#b8860b",
+ "gray": "#deb887",
+ "green": "#ffa500",
+ "magenta": "#d2691e",
+ "red": "#ff4500",
+ "white": "#fdf5eb",
+ "yellow": "#ffd700"
}
diff --git a/colors/pink.json b/colors/pink.json
index 497a5e43..762a8a90 100644
--- a/colors/pink.json
+++ b/colors/pink.json
@@ -1,6 +1,10 @@
{
- "gray": "#BCA3A3",
- "green": "#ff1493",
- "red": "#dc143c",
- "yellow": "#ff4500"
+ "blue": "#8a2be2",
+ "cyan": "#800080",
+ "gray": "#d8bfd8",
+ "green": "#ff00ff",
+ "magenta": "#db7093",
+ "red": "#ff1493",
+ "white": "#fff0f5",
+ "yellow": "#ffc0cb"
}
diff --git a/colors/solarized.json b/colors/solarized.json
new file mode 100644
index 00000000..62069b2b
--- /dev/null
+++ b/colors/solarized.json
@@ -0,0 +1,10 @@
+{
+ "black": "#073642",
+ "blue": "#268bd2",
+ "cyan": "#2aa198",
+ "green": "#859900",
+ "magenta": "#d33682",
+ "red": "#dc322f",
+ "white": "#eee8d5",
+ "yellow": "#b58900"
+}
diff --git a/colors/solarized.light.json b/colors/solarized.light.json
new file mode 100644
index 00000000..e22c61d3
--- /dev/null
+++ b/colors/solarized.light.json
@@ -0,0 +1,10 @@
+{
+ "black": "#262626",
+ "blue": "#0087ff",
+ "cyan": "#00afaf",
+ "green": "#5f8700",
+ "magenta": "#af005f",
+ "red": "#d70000",
+ "white": "#d7d7af",
+ "yellow": "#af8700"
+}
diff --git a/docs/advanced.md b/docs/advanced.md
index 5af7c6ff..42904e91 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -3,20 +3,46 @@ layout: default
title: Advanced Topic
---
+* [Aliases](#aliases)
* [Auto Login](#auto-login)
* [Bash Completion](#bash-completion)
* [Cache](#cache)
* [Configuration](#configuration)
-* [Color Theme](#color-theme)
-* [Log Level](#log-level)
-
-# Auto login
+* [Color Themes](#color-themes)
+* [File Name](#file-name)
+* [Log Levels](#log-levels)
+* [Plugins](#plugins)
+
+# Aliases
+
+The commands in leetcode-cli usually has builtin aliases as below:
+
+|Command |Aliases |
+|----------|-----------------------|
+|config |conf, cfg, setting |
+|list |ls |
+|plugin |extension, ext |
+|session |branch |
+|show |view, pick |
+|star |like, favorite |
+|stat |stats, progress, report|
+|submission|pull |
+|submit |push, commit |
+|test |run |
+|user |account |
+|version |info, env |
+
+# Auto Login
Leetcode.com is restricting only one session alive in the same time, which means if you login same account otherwhere, the existing login session will be expired immediately. This will greatly harm your experience since you have to re-login again and again among different sessions.
The good news is leetcode-cli will help a lot on this by trying re-login transparently and automatically without interrupting your current work whenever it detects your current session is expired. To enable this feature you could add following in your config then login again:
- "AUTO_LOGIN": true
+ {
+ "autologin": {
+ "enable": true
+ }
+ }
**NOTE: once enabled, your PASSWORD will be persisted locally for further using, so PLEASE be careful to ONLY enable this on your OWN computer for the sake of security!**
@@ -24,12 +50,12 @@ The good news is leetcode-cli will help a lot on this by trying re-login transpa
Copy `.lc-completion.bash` to your home directory, and source it in .bashrc (Linux) or .bash_profile (MacOS).
- $ cp .lc-completion.bash ~
- $ echo "source ~/.lc-completion.bash" >> ~/.bashrc
- $ source ~/.bashrc
+ $ cp .lc-completion.bash ~
+ $ echo "source ~/.lc-completion.bash" >> ~/.bashrc
+ $ source ~/.bashrc
- $ leetcode list ---Given two strings s and t which consist of only lowercase letters.
- -String t is generated by random shuffling string s and then add one more letter at a random position.
- -Find the letter that was added in t.
- -Example: -
-Input: -s = "abcd" -t = "abcde" - -Output: -e - -Explanation: -'e' is the letter that was added. -- -
Subscribe to see which companies asked this question
-- - Discuss - - - - - Pick One -
- -\r\nGiven two strings s and t which consist of only lowercase letters.
\r\n\r\nString t is generated by random shuffling string s and then add one more letter at a random position.
\r\n\r\nFind the letter that was added in t.
\r\n\r\nExample:\r\n
\r\nInput:\r\ns = \"abcd\"\r\nt = \"abcde\"\r\n\r\nOutput:\r\ne\r\n\r\nExplanation:\r\n'e' is the letter that was added.\r\n","stats":"{\"totalAccepted\": \"89.7K\", \"totalSubmission\": \"175.7K\"}","codeDefinition":"[{\"text\": \"C++\", \"value\": \"cpp\", \"defaultCode\": \"class Solution {\\r\\npublic:\\r\\n char findTheDifference(string s, string t) {\\r\\n \\r\\n }\\r\\n};\"}, {\"text\": \"Java\", \"value\": \"java\", \"defaultCode\": \"class Solution {\\r\\n public char findTheDifference(String s, String t) {\\r\\n \\r\\n }\\r\\n}\"}, {\"text\": \"Python\", \"value\": \"python\", \"defaultCode\": \"class Solution(object):\\r\\n def findTheDifference(self, s, t):\\r\\n \\\"\\\"\\\"\\r\\n :type s: str\\r\\n :type t: str\\r\\n :rtype: str\\r\\n \\\"\\\"\\\"\\r\\n \"}, {\"text\": \"Python3\", \"value\": \"python3\", \"defaultCode\": \"class Solution:\\r\\n def findTheDifference(self, s, t):\\r\\n \\\"\\\"\\\"\\r\\n :type s: str\\r\\n :type t: str\\r\\n :rtype: str\\r\\n \\\"\\\"\\\"\\r\\n \"}, {\"text\": \"C\", \"value\": \"c\", \"defaultCode\": \"char findTheDifference(char* s, char* t) {\\r\\n \\r\\n}\"}, {\"text\": \"C#\", \"value\": \"csharp\", \"defaultCode\": \"public class Solution {\\r\\n public char FindTheDifference(string s, string t) {\\r\\n \\r\\n }\\r\\n}\"}, {\"text\": \"JavaScript\", \"value\": \"javascript\", \"defaultCode\": \"/**\\r\\n * @param {string} s\\r\\n * @param {string} t\\r\\n * @return {character}\\r\\n */\\r\\nvar findTheDifference = function(s, t) {\\r\\n \\r\\n};\"}, {\"text\": \"Ruby\", \"value\": \"ruby\", \"defaultCode\": \"# @param {String} s\\r\\n# @param {String} t\\r\\n# @return {Character}\\r\\ndef find_the_difference(s, t)\\r\\n \\r\\nend\"}, {\"text\": \"Swift\", \"value\": \"swift\", \"defaultCode\": \"class Solution {\\r\\n func findTheDifference(_ s: String, _ t: String) -> Character {\\r\\n \\r\\n }\\r\\n}\"}, {\"text\": \"Go\", \"value\": \"golang\", \"defaultCode\": \"func findTheDifference(s string, t string) byte {\\r\\n \\r\\n}\"}, {\"text\": \"Scala\", \"value\": \"scala\", \"defaultCode\": \"object Solution {\\n def findTheDifference(s: String, t: String): Char = {\\n \\n }\\n}\"}, {\"text\": \"Kotlin\", \"value\": \"kotlin\", \"defaultCode\": \"class Solution {\\n fun findTheDifference(s: String, t: String): Char {\\n \\n }\\n}\"}]","sampleTestCase":"\"abcd\"\n\"abcde\"","enableRunCode":true,"metaData":"{\r\n \"name\": \"findTheDifference\",\r\n \"params\": [\r\n {\r\n \"name\": \"s\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"name\": \"t\",\r\n \"type\": \"string\"\r\n }\r\n ],\r\n \"return\": {\r\n \"type\": \"character\"\r\n }\r\n}","discussCategoryId":"511"}}} \ No newline at end of file diff --git a/test/mock/two-sum.submissions.html.20161006 b/test/mock/two-sum.submissions.html.20161006 deleted file mode 100644 index 28f02f97..00000000 --- a/test/mock/two-sum.submissions.html.20161006 +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - -
| - Submit Time - | -- Question - | -- Status - | -- Run Time - | - -- Language - | -
|---|---|---|---|---|
| 3 weeks, 4 days ago | -- Two Sum - | -- - Accepted - - | -- 9 ms - | -cpp | -
| 3 weeks, 6 days ago | -- Two Sum - | -- - Wrong Answer - - | -- N/A - | -cpp | -