Skip to content

Commit 2d06e47

Browse files
committed
Refactor README.md to doc folder
Signed-off-by: Eric Wang <[email protected]>
1 parent 6719260 commit 2d06e47

File tree

3 files changed

+299
-234
lines changed

3 files changed

+299
-234
lines changed

Diff for: README.md

-234
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@ Great thanks to leetcode.com, an really awesome website!
1717
* Support case [**TEST**](#test) and [**SUBMIT**](#submit) to leetcode.com.
1818
* [**AUTO LOGIN**](#auto-login) among multiple sessions with single leetcode account.
1919

20-
## Table of Contents
21-
22-
* [Prerequisites](#prerequisites)
23-
* [Install](#install)
24-
* [Best Practice](#best-practice)
25-
* [Commands](#commands)
26-
* [help](#help)
27-
* [list](#list)
28-
* [show](#show)
29-
* [submit](#submit)
30-
* [test](#test)
31-
* [user](#user)
32-
* [version](#version)
33-
* [Tips](#tips)
34-
* [Bash Completion](#bash-completion)
35-
* [Colorful Output](#colorful-output)
36-
* [Configuration](#configuration)
37-
* [Auto Login](#auto-login)
38-
3920
## Prerequisites
4021

4122
node.js (npm included), please follow the installation guide below:
@@ -63,218 +44,3 @@ From source code:
6344
Coding it!
6445
Run test(s) and pray $ lc test ./two-sum.cpp -t '[3,2,4]\n7'
6546
Submit final solution! $ lc submit ./two-sum.cpp
66-
67-
## Commands
68-
69-
### help
70-
71-
list [keyword] list problems
72-
show <keyword> show problem by name or index
73-
submit <filename> submit final solution to leetcode
74-
test <filename> send solution to leetcode and run test
75-
user login/logout with leetcode account
76-
version show version info
77-
78-
* `lc help <command>` to see help on sub command.
79-
* `lc <command> --help` also works.
80-
81-
### list
82-
83-
Navigate all the problems. The heading `` means you have AC-ed the problem.
84-
85-
$ lc list
86-
87-
[385] Mini Parser Medium (26.5%)
88-
✘ [384] Shuffle an Array Medium (45.7%)
89-
✔ [383] Ransom Note Easy (44.5%)
90-
✔ [382] Linked List Random Node Medium (46.6%)
91-
......
92-
✔ [ 4] Median of Two Sorted Arrays Hard (19.6%)
93-
✔ [ 3] Longest Substring Without Repeating Characters Medium (22.9%)
94-
✔ [ 2] Add Two Numbers Medium (24.5%)
95-
✔ [ 1] Two Sum Easy (25.6%)
96-
97-
* `-q` to filter by query conditions.
98-
* `e` = easy, `E` = m + h.
99-
* `m` = medium, `M` = e + h.
100-
* `h` = hard, `H` = e + m.
101-
* `d` = done = AC-ed, `D` = not AC-ed.
102-
* `l` = locked, `L` = not locked.
103-
* `-s` to show statistic counters.
104-
* `lc list <keyword>` to search by keyword.
105-
106-
*Example*
107-
108-
$ lc list -q Dml array
109-
🔒 [360] Sort Transformed Array Medium (41.0%)
110-
🔒 [325] Maximum Size Subarray Sum Equals k Medium (40.9%)
111-
112-
### show
113-
114-
Select a problem to fight. With `-g`+`-l`, the code template could be auto generated for you.
115-
116-
$ lc show 1 -g -l cpp
117-
118-
[1] Two Sum (File: two-sum.cpp)
119-
120-
https://leetcode.com/problems/two-sum/
121-
122-
* Easy (25.6%)
123-
* Total Accepted: 274880
124-
* Total Submissions: 1074257
125-
126-
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
127-
128-
You may assume that each input would have exactly one solution.
129-
130-
Example:
131-
132-
Given nums = [2, 7, 11, 15], target = 9,
133-
134-
Because nums[0] + nums[1] = 2 + 7 = 9,
135-
return [0, 1].
136-
137-
UPDATE (2016/2/13):
138-
The return format had been changed to zero-based indices. Please read the above updated description carefully.
139-
140-
* `-g` to generate source file.
141-
* `-l` to choose programming language. (Depends on which langs are provided on leetcode)
142-
* c
143-
* cpp
144-
* csharp
145-
* golang
146-
* java
147-
* javascript
148-
* python
149-
* ruby
150-
* swift
151-
* Instead of index number, you can use name to select a problem.
152-
* `lc show "Two Sum"`
153-
* `lc show two-sum`
154-
155-
### submit
156-
157-
$ lc submit ./two-sum.cpp
158-
✔ Accepted
159-
✔ 16/16 cases passed (12 ms)
160-
161-
### test
162-
163-
Customize your testcase and run it against leetcode.
164-
165-
$ lc test ./two-sum.cpp -t '[3,2,4]\n7'
166-
167-
Input data:
168-
[3,2,4]
169-
7
170-
171-
Your
172-
✔ runtime: 0 ms
173-
✘ answer: [1,2]
174-
✔ output:
175-
176-
Expected
177-
✔ runtime: 0 ms
178-
✔ answer: [0,2]
179-
✔ output:
180-
181-
* `-t` to provide test case in command line.
182-
* `-i` to provide test case in interactive mode.
183-
184-
### user
185-
186-
Login with your leetcode account (username or email).
187-
188-
$ lc user -l
189-
login: <account>
190-
pass:
191-
Successfully login as <account>
192-
193-
* `-l` to login
194-
* `-L` to logout.
195-
* `-s` to show user statistics.
196-
* `lc user` to show current account.
197-
198-
*Eaxmple*
199-
200-
$ lc user -s
201-
You are now login as skygragon
202-
203-
Easy 72/95 (75.79%) [+++++++++++++++++++++++.......]
204-
Medium 97/194 (50.00%) [+++++++++++++++...............]
205-
Hard 27/82 (32.93%) [++++++++++....................]
206-
207-
### version
208-
209-
$ lc version
210-
0.4.0
211-
212-
* `-v` to show verbose info, e.g. config, cache dir.
213-
214-
*Example*
215-
216-
$ lc version -v
217-
_ _ _
218-
| | | | | |
219-
| | ___ ___| |_ ___ ___ __| | ___
220-
| |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \
221-
| | __/ __/ |_ (__| (_) | (_| | __/
222-
|_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v0.4.0
223-
224-
[Environment]
225-
Cache: /Users/skygragon/.lc/
226-
Config: /Users/skygragon/.lcconfig
227-
228-
[Configuration]
229-
BASE_URL: https://leetcode.com
230-
LOGIN_URL: https://leetcode.com/accounts/login/
231-
PROBLEMS_URL: https://leetcode.com/api/problems/algorithms/
232-
PROBLEM_URL: https://leetcode.com/problems/$id
233-
TEST_URL: https://leetcode.com/problems/$key/interpret_solution/
234-
SUBMIT_URL: https://leetcode.com/problems/$key/submit/
235-
VERIFY_URL: https://leetcode.com/submissions/detail/$id/check/
236-
LANG: java
237-
USE_COLOR: true
238-
AUTO_LOGIN: true
239-
240-
## Tips
241-
242-
### Bash Completion
243-
244-
Copy `.lc-completion.bash` to your home directory, and source it in .bashrc (Linux) or .bash_profile (MacOS).
245-
246-
$ cp .lc-completion.bash ~
247-
$ echo "source ~/.lc-completion.bash" >> ~/.bashrc
248-
$ source ~/.bashrc
249-
250-
$ lc list --<tab>
251-
--help --keyword --query --stat
252-
253-
### Colorful Output
254-
255-
* `--color` to enable color.
256-
* `--no-color` to disable it.
257-
258-
Or use configuration setting, see below.
259-
260-
### Configuration
261-
262-
Create a file named `.lcconfig` in your home directory.
263-
264-
*Example*
265-
266-
{
267-
"LANG": "java",
268-
"USE_COLOR": true,
269-
"AUTO_LOGIN": false
270-
}
271-
272-
### Auto login
273-
274-
Leetcode.com is restricting one session only in the same time, which means if you have 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.
275-
276-
However leetcode-cli will help some one this.It will try to save you from this trial and re-login transparently without interrupting your current work whenever it notices the session is already expired. To enable this in your config:
277-
278-
"AUTO_LOGIN": true
279-
280-
**NOTE: if enabled, your PASSWORD will be persisted locally to achieve auto login, so PLEASE be careful to ONLY enable this on your OWN computer for the sake of security!**

Diff for: doc/advanced.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Table of Contents
2+
3+
* [Bash Completion](#bash-completion)
4+
* [Colorful Output](#colorful-output)
5+
* [Configuration](#configuration)
6+
* [Cache](#cache)
7+
* [Auto Login](#auto-login)
8+
9+
10+
## Bash Completion
11+
12+
Copy `.lc-completion.bash` to your home directory, and source it in .bashrc (Linux) or .bash_profile (MacOS).
13+
14+
$ cp .lc-completion.bash ~
15+
$ echo "source ~/.lc-completion.bash" >> ~/.bashrc
16+
$ source ~/.bashrc
17+
18+
$ lc list --<tab>
19+
--help --keyword --query --stat
20+
21+
**NOTE: it might become slower in bash with this enabled, personally I would NOT suggest to use it...**
22+
23+
## Colorful Output
24+
25+
* `--color` to enable color.
26+
* `--no-color` to disable it.
27+
28+
Or use configuration setting to avoid typing it repeatedly, see [below](#configuration).
29+
30+
## Configuration
31+
32+
Create a JSON file named `.lcconfig` in your home directory, e.g.
33+
34+
$ cat ~/.lcconfig
35+
36+
{
37+
"LANG": "java",
38+
"USE_COLOR": true,
39+
"AUTO_LOGIN": false
40+
}
41+
42+
Here are some useful settings:
43+
44+
* `AUTO_LOGIN` to enable auto login feature, see [below](#auto-login)
45+
* `LANG` to set default language in coding.
46+
* `USE_COLOR` to set colorful output or not by default.
47+
48+
## Cache
49+
50+
The local cache folder (`.lc/`) is in your home directory, e.g.
51+
52+
$ ls -a1 ~/.lc/
53+
54+
.user.json # user info
55+
all.json # problems list
56+
two-sum.json # specific problem info
57+
58+
59+
## Auto login
60+
61+
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.
62+
63+
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:
64+
65+
"AUTO_LOGIN": true
66+
67+
**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!**

0 commit comments

Comments
 (0)