@night-slayer18/leetcode-cli 2.2.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +26 -0
- package/.prettierrc +10 -0
- package/README.md +98 -76
- package/dist/index.js +273 -243
- package/package.json +8 -2
package/.prettierignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Build outputs
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
*.tsbuildinfo
|
|
5
|
+
|
|
6
|
+
# Dependencies
|
|
7
|
+
node_modules/
|
|
8
|
+
package-lock.json
|
|
9
|
+
|
|
10
|
+
# Coverage
|
|
11
|
+
coverage/
|
|
12
|
+
.nyc_output/
|
|
13
|
+
|
|
14
|
+
# Logs
|
|
15
|
+
*.log
|
|
16
|
+
|
|
17
|
+
# OS files
|
|
18
|
+
.DS_Store
|
|
19
|
+
Thumbs.db
|
|
20
|
+
|
|
21
|
+
# Auto-generated files
|
|
22
|
+
*.min.js
|
|
23
|
+
*.min.css
|
|
24
|
+
|
|
25
|
+
# License (preserve original formatting)
|
|
26
|
+
LICENSE
|
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -26,15 +26,17 @@ A modern, feature-rich LeetCode CLI built with TypeScript.
|
|
|
26
26
|
- 👥 **Collaborative coding** - Solve problems with a partner
|
|
27
27
|
- 📁 **Workspaces** - Isolate contexts (interview prep, study, contests)
|
|
28
28
|
- ⚙️ **Configurable** - Set language, editor, and working directory
|
|
29
|
+
- 🖥️ **Interactive TUI** - Launch full-screen terminal workflow with `leetcode`
|
|
29
30
|
- 📂 **Smart file discovery** - Use problem ID, filename, or full path
|
|
30
31
|
- 🔄 **Git Sync** - Auto-sync solutions to GitHub/GitLab
|
|
31
32
|
- 🚀 **Auto-update notifications** - Get notified when updates are available
|
|
32
33
|
|
|
33
|
-
|
|
34
34
|
## 📚 Documentation
|
|
35
35
|
|
|
36
36
|
**[View Full Documentation →](https://night-slayer18.github.io/leetcode-cli/)**
|
|
37
37
|
|
|
38
|
+
**[TUI Guide →](docs/tui.md)**
|
|
39
|
+
|
|
38
40
|
**[Read the Blog Post →](https://leetcode-cli.hashnode.dev/leetcode-cli)**
|
|
39
41
|
|
|
40
42
|
## Installation
|
|
@@ -46,6 +48,9 @@ npm install -g @night-slayer18/leetcode-cli
|
|
|
46
48
|
## Quick Start
|
|
47
49
|
|
|
48
50
|
```bash
|
|
51
|
+
# Launch interactive TUI mode
|
|
52
|
+
leetcode
|
|
53
|
+
|
|
49
54
|
# Login with your LeetCode cookies
|
|
50
55
|
leetcode login
|
|
51
56
|
|
|
@@ -64,37 +69,46 @@ leetcode test ./Easy/Array/1.two-sum.java # Full path
|
|
|
64
69
|
leetcode submit 1
|
|
65
70
|
```
|
|
66
71
|
|
|
67
|
-
##
|
|
72
|
+
## Interactive TUI
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|---------|-------------|
|
|
71
|
-
| `login` | Login with LeetCode browser cookies |
|
|
72
|
-
| `logout` | Clear stored credentials |
|
|
73
|
-
| `whoami` | Check login status |
|
|
74
|
-
| `today` | Show daily progress & challenge |
|
|
75
|
-
| `list` | List problems with filters |
|
|
76
|
-
| `show <id>` | Display problem description |
|
|
77
|
-
| `hint <id>` | Show hints for a problem |
|
|
78
|
-
| `pick <id>` | Generate solution file |
|
|
79
|
-
| `pick-batch <ids>` | Pick multiple problems |
|
|
80
|
-
| `bookmark <action>` | Manage problem bookmarks |
|
|
81
|
-
| `note <id>` | Manage problem notes |
|
|
82
|
-
| `daily` | Show today's challenge |
|
|
83
|
-
| `random` | Get a random problem |
|
|
84
|
-
| `test <id\|file>` | Test solution against sample cases |
|
|
85
|
-
| `submit <id\|file>` | Submit solution to LeetCode |
|
|
86
|
-
| `submissions <id>` | View past submissions |
|
|
87
|
-
| `stat [username]` | Show user statistics |
|
|
88
|
-
| `timer <id>` | Interview mode with timer |
|
|
89
|
-
| `snapshot <cmd>` | Save and restore solution versions |
|
|
90
|
-
| `diff <id>` | Compare solution with past submissions |
|
|
91
|
-
| `collab <cmd>` | Collaborative coding with a partner |
|
|
92
|
-
| `workspace <cmd>` | Manage workspaces for different contexts |
|
|
93
|
-
| `config` | View or set configuration |
|
|
94
|
-
| `sync` | Sync solutions to Git repository |
|
|
95
|
-
| `update` | Check for CLI updates |
|
|
96
|
-
| `changelog` | View release notes and breaking changes |
|
|
74
|
+
Run `leetcode` with no arguments to open the full-screen TUI.
|
|
97
75
|
|
|
76
|
+
- Works in interactive terminals (TTY).
|
|
77
|
+
- Keeps existing command shortcuts for problem actions (`p/t/s/h/H/V/b/n/e`).
|
|
78
|
+
- Uses a unified bottom drawer in Problem view for hints, submissions, snapshots, notes, and status output.
|
|
79
|
+
|
|
80
|
+
See [docs/tui.md](docs/tui.md) for full keybindings and behavior.
|
|
81
|
+
|
|
82
|
+
## Commands
|
|
83
|
+
|
|
84
|
+
| Command | Description |
|
|
85
|
+
| ------------------- | ---------------------------------------- |
|
|
86
|
+
| `login` | Login with LeetCode browser cookies |
|
|
87
|
+
| `logout` | Clear stored credentials |
|
|
88
|
+
| `whoami` | Check login status |
|
|
89
|
+
| `today` | Show daily progress & challenge |
|
|
90
|
+
| `list` | List problems with filters |
|
|
91
|
+
| `show <id>` | Display problem description |
|
|
92
|
+
| `hint <id>` | Show hints for a problem |
|
|
93
|
+
| `pick <id>` | Generate solution file |
|
|
94
|
+
| `pick-batch <ids>` | Pick multiple problems |
|
|
95
|
+
| `bookmark <action>` | Manage problem bookmarks |
|
|
96
|
+
| `note <id>` | Manage problem notes |
|
|
97
|
+
| `daily` | Show today's challenge |
|
|
98
|
+
| `random` | Get a random problem |
|
|
99
|
+
| `test <id\|file>` | Test solution against sample cases |
|
|
100
|
+
| `submit <id\|file>` | Submit solution to LeetCode |
|
|
101
|
+
| `submissions <id>` | View past submissions |
|
|
102
|
+
| `stat [username]` | Show user statistics |
|
|
103
|
+
| `timer <id>` | Interview mode with timer |
|
|
104
|
+
| `snapshot <cmd>` | Save and restore solution versions |
|
|
105
|
+
| `diff <id>` | Compare solution with past submissions |
|
|
106
|
+
| `collab <cmd>` | Collaborative coding with a partner |
|
|
107
|
+
| `workspace <cmd>` | Manage workspaces for different contexts |
|
|
108
|
+
| `config` | View or set configuration |
|
|
109
|
+
| `sync` | Sync solutions to Git repository |
|
|
110
|
+
| `update` | Check for CLI updates |
|
|
111
|
+
| `changelog` | View release notes and breaking changes |
|
|
98
112
|
|
|
99
113
|
## Usage Examples
|
|
100
114
|
|
|
@@ -142,6 +156,7 @@ leetcode pick 1
|
|
|
142
156
|
|
|
143
157
|
# Specify language
|
|
144
158
|
leetcode pick 1 --lang python3
|
|
159
|
+
leetcode pick 175 --lang sql
|
|
145
160
|
|
|
146
161
|
# Skip opening in editor
|
|
147
162
|
leetcode pick 1 --no-open
|
|
@@ -204,21 +219,21 @@ leetcode submissions 1 --download
|
|
|
204
219
|
```
|
|
205
220
|
|
|
206
221
|
### Productivity Features
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Show today's progress & challenge
|
|
225
|
+
leetcode today
|
|
226
|
+
|
|
227
|
+
# Pick multiple problems at once
|
|
228
|
+
leetcode pick-batch 1 2 3 -l python3
|
|
229
|
+
|
|
230
|
+
# Bookmark problems
|
|
231
|
+
leetcode bookmark add 1
|
|
232
|
+
leetcode bookmark list
|
|
233
|
+
|
|
234
|
+
# Keep personal notes
|
|
235
|
+
leetcode note 1 edit
|
|
236
|
+
```
|
|
222
237
|
|
|
223
238
|
### User Statistics
|
|
224
239
|
|
|
@@ -236,12 +251,12 @@ leetcode stat -s
|
|
|
236
251
|
leetcode stat -t
|
|
237
252
|
```
|
|
238
253
|
|
|
239
|
-
|
|
254
|
+
### Git Integration
|
|
240
255
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
256
|
+
```bash
|
|
257
|
+
# Sync all solutions to your configured git repo
|
|
258
|
+
leetcode sync
|
|
259
|
+
```
|
|
245
260
|
|
|
246
261
|
### Interview Timer
|
|
247
262
|
|
|
@@ -339,8 +354,8 @@ leetcode workspace delete old-workspace
|
|
|
339
354
|
```
|
|
340
355
|
|
|
341
356
|
Each workspace has its own config, timer history, and solution snapshots.
|
|
342
|
-
|
|
343
|
-
|
|
357
|
+
|
|
358
|
+
### Configuration
|
|
344
359
|
|
|
345
360
|
```bash
|
|
346
361
|
# View current config
|
|
@@ -351,6 +366,7 @@ leetcode config -i
|
|
|
351
366
|
|
|
352
367
|
# Set specific options
|
|
353
368
|
leetcode config --lang python3
|
|
369
|
+
leetcode config --lang sql
|
|
354
370
|
leetcode config --editor code
|
|
355
371
|
leetcode config --workdir ~/leetcode
|
|
356
372
|
leetcode config --repo https://github.com/username/leetcode-solutions.git
|
|
@@ -377,19 +393,20 @@ leetcode/
|
|
|
377
393
|
|
|
378
394
|
## Supported Languages
|
|
379
395
|
|
|
380
|
-
| Language
|
|
381
|
-
|
|
382
|
-
| TypeScript | `.ts`
|
|
383
|
-
| JavaScript | `.js`
|
|
384
|
-
| Python3
|
|
385
|
-
| Java
|
|
386
|
-
| C++
|
|
387
|
-
| C
|
|
388
|
-
| C#
|
|
389
|
-
| Go
|
|
390
|
-
| Rust
|
|
391
|
-
| Kotlin
|
|
392
|
-
| Swift
|
|
396
|
+
| Language | Extension |
|
|
397
|
+
| ---------- | --------- |
|
|
398
|
+
| TypeScript | `.ts` |
|
|
399
|
+
| JavaScript | `.js` |
|
|
400
|
+
| Python3 | `.py` |
|
|
401
|
+
| Java | `.java` |
|
|
402
|
+
| C++ | `.cpp` |
|
|
403
|
+
| C | `.c` |
|
|
404
|
+
| C# | `.cs` |
|
|
405
|
+
| Go | `.go` |
|
|
406
|
+
| Rust | `.rs` |
|
|
407
|
+
| Kotlin | `.kt` |
|
|
408
|
+
| Swift | `.swift` |
|
|
409
|
+
| SQL | `.sql` |
|
|
393
410
|
|
|
394
411
|
## Authentication
|
|
395
412
|
|
|
@@ -450,6 +467,7 @@ You can run the CLI using Docker without installing Node.js.
|
|
|
450
467
|
### Method 1: Pre-built Image (Recommended)
|
|
451
468
|
|
|
452
469
|
1. **Pull the image**:
|
|
470
|
+
|
|
453
471
|
```bash
|
|
454
472
|
docker pull nightslayer/leetcode-cli:latest
|
|
455
473
|
```
|
|
@@ -457,6 +475,7 @@ You can run the CLI using Docker without installing Node.js.
|
|
|
457
475
|
2. **Setup Shell Function** (Add to your shell config):
|
|
458
476
|
|
|
459
477
|
**Bash/Zsh** (`~/.bashrc` or `~/.zshrc`):
|
|
478
|
+
|
|
460
479
|
```bash
|
|
461
480
|
leetcode() {
|
|
462
481
|
docker run -it --rm \
|
|
@@ -468,6 +487,7 @@ You can run the CLI using Docker without installing Node.js.
|
|
|
468
487
|
```
|
|
469
488
|
|
|
470
489
|
**Fish** (`~/.config/fish/config.fish`):
|
|
490
|
+
|
|
471
491
|
```fish
|
|
472
492
|
function leetcode
|
|
473
493
|
docker run -it --rm \
|
|
@@ -479,6 +499,7 @@ You can run the CLI using Docker without installing Node.js.
|
|
|
479
499
|
```
|
|
480
500
|
|
|
481
501
|
**PowerShell** (`$PROFILE`):
|
|
502
|
+
|
|
482
503
|
```powershell
|
|
483
504
|
function leetcode {
|
|
484
505
|
docker run -it --rm `
|
|
@@ -498,19 +519,20 @@ You can run the CLI using Docker without installing Node.js.
|
|
|
498
519
|
### Method 2: Build Locally
|
|
499
520
|
|
|
500
521
|
1. **Build the image**:
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
docker build -t leetcode-cli .
|
|
525
|
+
```
|
|
504
526
|
|
|
505
527
|
2. **Run commands**:
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
528
|
+
```bash
|
|
529
|
+
docker run -it --rm \
|
|
530
|
+
-w /root/leetcode \
|
|
531
|
+
-v "$(pwd)/leetcode:/root/leetcode" \
|
|
532
|
+
-v "$HOME/.leetcode:/root/.leetcode" \
|
|
533
|
+
leetcode-cli list
|
|
534
|
+
```
|
|
535
|
+
_Note: We mount `~/.leetcode` to persist login credentials and `leetcode` folder to save solution files._
|
|
514
536
|
|
|
515
537
|
## License
|
|
516
538
|
|