-* https://nodejs.org/en/download/
-* https://nodejs.org/en/download/package-manager/
+A productive cli tool to enjoy leetcode!
-## Install
+Great thanks to leetcode.com, a really awesome website!
-From npm repo:
+⦙ [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) ⦙
- $ sudo npm install -g leetcode-cli
+* 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!
-From source code:
+## Screenshot
- $ git clone http://github.com/skygragon/leetcode-cli
- $ cd leetcode-cli && npm install && sudo npm install -g .
+
## 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
-
-## There is More...
-
-* [Commands Tutorial](https://github.com/skygragon/leetcode-cli/blob/master/doc/commands.md)
-* [Advanced Tips](https://github.com/skygragon/leetcode-cli/blob/master/doc/advanced.md)
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
new file mode 100755
index 00000000..6f39955a
--- /dev/null
+++ b/bin/install
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+ENVFILE=.env.json
+
+check() {
+ printf "Checking $1 ... "
+ $1 --version > /dev/null 2>&1
+ if [ $? != 0 ]; then
+ echo "No"
+ echo "[ERROR] Missing $1!"
+ exit 1;
+ fi
+ echo "Yes"
+}
+
+create() {
+ cat << EOF > $1
+{
+ "commit": {
+ "full": "`git rev-parse HEAD`",
+ "short": "`git rev-parse --short HEAD`"
+ },
+ "node": "`node -v`",
+ "npm": "`npm -v`"
+}
+EOF
+}
+
+check git
+check node
+check npm
+
+create $ENVFILE
+
+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
new file mode 100644
index 00000000..7577d79d
--- /dev/null
+++ b/colors/blue.json
@@ -0,0 +1,10 @@
+{
+ "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
new file mode 100644
index 00000000..86e60471
--- /dev/null
+++ b/colors/dark.json
@@ -0,0 +1,9 @@
+{
+ "blue": "#000099",
+ "cyan": "#009999",
+ "gray": "#455354",
+ "green": "#009900",
+ "magenta": "#990099",
+ "red": "#990000",
+ "yellow": "#999900"
+}
diff --git a/colors/default.json b/colors/default.json
new file mode 100644
index 00000000..d17a20a9
--- /dev/null
+++ b/colors/default.json
@@ -0,0 +1,11 @@
+{
+ "black": "#000000",
+ "blue": "#0000ff",
+ "cyan": "#00ffff",
+ "gray": "#999999",
+ "green": "#00ff00",
+ "magenta": "#ff00ff",
+ "red": "#ff0000",
+ "white": "#ffffff",
+ "yellow": "#ffff00"
+}
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
new file mode 100644
index 00000000..2fcc4378
--- /dev/null
+++ b/colors/orange.json
@@ -0,0 +1,10 @@
+{
+ "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
new file mode 100644
index 00000000..762a8a90
--- /dev/null
+++ b/colors/pink.json
@@ -0,0 +1,10 @@
+{
+ "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/doc/advanced.md b/doc/advanced.md
deleted file mode 100644
index 6b372d8f..00000000
--- a/doc/advanced.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# Table of Contents
-
-* [Bash Completion](#bash-completion)
-* [Colorful Output](#colorful-output)
-* [Debug Output](#debug-output)
-* [Configuration](#configuration)
-* [Cache](#cache)
-* [Auto Login](#auto-login)
-
-
-## Bash Completion
-
-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
-
- $ 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 | -