Skip to content

Commit e019025

Browse files
committed
fixed --help cli command error
1 parent 76afe63 commit e019025

File tree

7 files changed

+39
-8
lines changed

7 files changed

+39
-8
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Set up Python
1414
uses: actions/setup-python@v4
1515
with:
16-
python-version: 3.6
16+
python-version: 3.8
1717
- name: Install Flit
1818
run: pip install flit
1919
- name: Install Dependencies

.github/workflows/test_full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
13+
python-version: ['3.7', '3.8', '3.9', '3.10']
1414

1515
steps:
1616
- uses: actions/checkout@v3

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test-cov: ## Run tests with coverage
3636

3737
doc-deploy: ## Run Deploy Documentation
3838
make clean
39-
mkdocs gh-deploy --force
39+
mkdocs gh-deploy --force --ignore-version
4040

4141

4242
pre-commit-lint: ## Runs Requires commands during pre-commit

ellar/cli/_main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def build_typers() -> None:
4444
options, args = getopt.getopt(
4545
sys.argv[1:],
4646
"p:",
47-
[
48-
"project=",
49-
],
47+
["project=", "help"],
5048
)
5149
app_name: t.Optional[str] = None
5250

tests/test_cli/sample_app/example_project_2/commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ def create_migration():
1414
def whatever_you_want():
1515
"""Whatever you want"""
1616
print("Whatever you want command from example_project_2")
17+
18+
19+
@command()
20+
def project_2_command():
21+
"""Project 2 Custom Command"""
22+
print("Project 2 Custom Command from example_project_2")

tests/test_cli/sample_app/example_project_2/root_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from ellar.core.connection import Request
44
from ellar.core.response import JSONResponse, Response
55

6-
from .commands import db, whatever_you_want
6+
from .commands import db, project_2_command, whatever_you_want
77

88

9-
@Module(commands=[db, whatever_you_want])
9+
@Module(commands=[db, whatever_you_want, project_2_command])
1010
class ApplicationModule(ModuleBase):
1111
@exception_handler(404)
1212
def exception_404_handler(cls, request: Request, exc: Exception) -> Response:

tests/test_cli/test_build_typers.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,30 @@ def test_build_typers_command_for_specific_project_works():
5252
)
5353
assert result.returncode == 0
5454
assert result.stdout == b"Whatever you want command from example_project_2\n"
55+
56+
57+
def test_help_command(cli_runner):
58+
os.chdir(sample_app_path)
59+
result = subprocess.run(["ellar", "--help"], stdout=subprocess.PIPE)
60+
assert result.returncode == 0
61+
assert (
62+
result.stdout
63+
== b"Usage: Ellar, Python Web framework [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n -p, --project TEXT Run Specific Command on a specific project\n --install-completion [bash|zsh|fish|powershell|pwsh]\n Install completion for the specified shell.\n --show-completion [bash|zsh|fish|powershell|pwsh]\n Show completion for the specified shell, to\n copy it or customize the installation.\n --help Show this message and exit.\n\nCommands:\n create-module - Scaffolds Ellar Application Module -\n create-project - Scaffolds Ellar Application -\n db\n runserver - Starts Uvicorn Server -\n say-hi\n whatever-you-want Whatever you want\n"
64+
)
65+
result = subprocess.run(
66+
["ellar", "-p", "example_project", "--help"], stdout=subprocess.PIPE
67+
)
68+
assert result.returncode == 0
69+
assert (
70+
result.stdout
71+
== b"Usage: Ellar, Python Web framework [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n -p, --project TEXT Run Specific Command on a specific project\n --install-completion [bash|zsh|fish|powershell|pwsh]\n Install completion for the specified shell.\n --show-completion [bash|zsh|fish|powershell|pwsh]\n Show completion for the specified shell, to\n copy it or customize the installation.\n --help Show this message and exit.\n\nCommands:\n create-module - Scaffolds Ellar Application Module -\n create-project - Scaffolds Ellar Application -\n db\n runserver - Starts Uvicorn Server -\n say-hi\n whatever-you-want Whatever you want\n"
72+
)
73+
74+
result = subprocess.run(
75+
["ellar", "-p", "example_project_2", "--help"], stdout=subprocess.PIPE
76+
)
77+
assert result.returncode == 0
78+
assert (
79+
result.stdout
80+
== b"Usage: Ellar, Python Web framework [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n -p, --project TEXT Run Specific Command on a specific project\n --install-completion [bash|zsh|fish|powershell|pwsh]\n Install completion for the specified shell.\n --show-completion [bash|zsh|fish|powershell|pwsh]\n Show completion for the specified shell, to\n copy it or customize the installation.\n --help Show this message and exit.\n\nCommands:\n create-module - Scaffolds Ellar Application Module -\n create-project - Scaffolds Ellar Application -\n db\n project-2-command Project 2 Custom Command\n runserver - Starts Uvicorn Server -\n say-hi\n whatever-you-want Whatever you want\n"
81+
)

0 commit comments

Comments
 (0)