Skip to content

Commit 52bca01

Browse files
feat: improve CLI entry point
1 parent 8ec3245 commit 52bca01

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,5 @@ lc daily py -e vim
5858

5959
#### Todo
6060

61-
- [ ] Implement test case management
6261
- [ ] Add support for custom test cases
63-
- [ ] Improve error handling
6462
- [ ] Add solution templates

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import find_packages, setup
22

33
setup(
44
name="leetcode-cli",
55
version="0.1.0",
66
packages=find_packages(),
7-
install_requires=[
8-
"typer",
9-
"requests",
10-
"gql[all]"
11-
],
127
entry_points={
138
"console_scripts": [
14-
"lc=src.main:app",
9+
"lc=src.main:main",
1510
],
16-
}
17-
)
11+
},
12+
)

src/lib/welcome.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import typer
2+
from rich.console import Console
3+
4+
console = Console()
5+
6+
7+
def get_leetcode_ascii():
8+
"""Return LeetCode ASCII art"""
9+
return """
10+
| _ _ |- _ | _
11+
|_(/_(/_|_(_()(|(/_
12+
"""
13+
14+
15+
def display_welcome(app: typer.Typer):
16+
"""Display welcome screen with ASCII art and command list"""
17+
console.print(get_leetcode_ascii())
18+
console.print(" Welcome to LeetCode CLI", style="bold")

src/main.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from src.commands.solution import solutions
1010
from src.commands.submit import submit
1111
from src.commands.test import test
12+
from src.lib.welcome import display_welcome
1213

1314
app = typer.Typer()
1415

@@ -23,5 +24,18 @@
2324
app.command(name="edit")(edit)
2425
app.command(name="solutions")(solutions)
2526

26-
if __name__ == "__main__":
27+
28+
@app.callback(invoke_without_command=True)
29+
def callback(ctx: typer.Context):
30+
"""LeetCode CLI - A command-line tool for LeetCode problems."""
31+
if ctx.invoked_subcommand is None:
32+
display_welcome(app)
33+
typer.echo(ctx.get_help())
34+
35+
36+
def main():
2737
app()
38+
39+
40+
if __name__ == "__main__":
41+
main()

0 commit comments

Comments
 (0)