Skip to content

Commit e42638c

Browse files
committed
Added clear util for cli
1 parent d4a2e9c commit e42638c

File tree

10 files changed

+51
-42
lines changed

10 files changed

+51
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,4 @@ __marimo__/
218218

219219
# Files and directories non related to python
220220
.secrets
221+
pre-commit

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
hooks:
2121
- id: flake8
2222
additional_dependencies: [flake8-bugbear]
23-
args: ["--config=./backend/.flake8"]
23+
args: ["--config=.flake8"]
2424

2525
# mypy - verificación de tipos
2626
- repo: https://github.com/pre-commit/mirrors-mypy
@@ -33,7 +33,7 @@ repos:
3333
yaspin,
3434
click,
3535
]
36-
args: [--config-file=./backend/pyproject.toml]
36+
args: [--config-file=pyproject.toml]
3737

3838
# Hooks básicos de git
3939
- repo: https://github.com/pre-commit/pre-commit-hooks

src/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from .__main__ import *
24

35
__version__ = "0.1.0"

src/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from click import group
24

35
from .cli.builder import Builder
@@ -8,6 +10,7 @@
810
def cli() -> None:
911
pass
1012

13+
1114
cli.add_command(Builder())
1215
cli.add_command(Manager())
1316

File renamed without changes.

src/cli/builder.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
from __future__ import annotations
2+
13
import inspect
24

3-
from click import Command, Option
45
from InquirerPy import inquirer
56
from InquirerPy.validator import EmptyInputValidator
7+
from click import Command, Option
68

79
from .custom_group import CustomGroup
10+
from ..utils.cli import clear
811

912

1013
class Builder(CustomGroup):
@@ -15,33 +18,29 @@ def __init__(self) -> None:
1518
def create(self) -> Command:
1619

1720
help = ""
18-
options = [
19-
Option()
20-
]
21+
options = [Option()]
2122

2223
def callback() -> None:
2324
pass
2425

2526
return Command(
26-
name=inspect.currentframe().f_code.co_name, # type: ignore
27+
name=inspect.currentframe().f_code.co_name, # type: ignore
2728
help=help,
2829
callback=callback,
29-
params=options # type: ignore
30+
params=options, # type: ignore
3031
)
31-
32+
3233
def update(self) -> Command:
3334

3435
help = ""
35-
options = [
36-
Option()
37-
]
36+
options = [Option()]
3837

3938
def callback() -> None:
4039
pass
4140

4241
return Command(
43-
name = inspect.currentframe().f_code.co_name, # type: ignore
42+
name=inspect.currentframe().f_code.co_name, # type: ignore
4443
help=help,
4544
callback=callback,
46-
params=options # type: ignore
47-
)
45+
params=options, # type: ignore
46+
)

src/cli/custom_group.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import annotations
2+
13
import inspect
24

3-
from click import Group, Command
5+
from click import Command, Group
46

57

68
class CustomGroup(Group):
@@ -13,4 +15,4 @@ def __register_commands(self) -> None:
1315
for _, method in inspect.getmembers(self, predicate=inspect.ismethod):
1416
result = method()
1517
if isinstance(result, Command):
16-
self.add_command(result)
18+
self.add_command(result)

src/cli/manager.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
from __future__ import annotations
2+
13
import inspect
24

3-
from click import Command, Option
45
from InquirerPy import inquirer
56
from InquirerPy.validator import EmptyInputValidator
7+
from click import Command, Option
68

79
from .custom_group import CustomGroup
10+
from ..utils.cli import clear
811

912

1013
class Manager(CustomGroup):
@@ -15,67 +18,59 @@ def __init__(self) -> None:
1518
def bakcup(self) -> Command:
1619

1720
help = ""
18-
options = [
19-
Option()
20-
]
21+
options = [Option()]
2122

2223
def callback() -> None:
2324
pass
2425

2526
return Command(
26-
name=inspect.currentframe().f_code.co_name, # type: ignore
27+
name=inspect.currentframe().f_code.co_name, # type: ignore
2728
help=help,
2829
callback=callback,
29-
params=options # type: ignore
30+
params=options, # type: ignore
3031
)
31-
32+
3233
def delete(self) -> Command:
3334

3435
help = ""
35-
options = [
36-
Option()
37-
]
36+
options = [Option()]
3837

3938
def callback() -> None:
4039
pass
4140

4241
return Command(
43-
name = inspect.currentframe().f_code.co_name, # type: ignore
42+
name=inspect.currentframe().f_code.co_name, # type: ignore
4443
help=help,
4544
callback=callback,
46-
params=options # type: ignore
45+
params=options, # type: ignore
4746
)
48-
47+
4948
def start(self) -> Command:
5049

5150
help = ""
52-
options = [
53-
Option()
54-
]
51+
options = [Option()]
5552

5653
def callback() -> None:
5754
pass
5855

5956
return Command(
60-
name=inspect.currentframe().f_code.co_name, # type: ignore
57+
name=inspect.currentframe().f_code.co_name, # type: ignore
6158
help=help,
6259
callback=callback,
63-
params=options # type: ignore
60+
params=options, # type: ignore
6461
)
65-
62+
6663
def stop(self) -> Command:
6764

6865
help = ""
69-
options = [
70-
Option()
71-
]
66+
options = [Option()]
7267

7368
def callback() -> None:
7469
pass
7570

7671
return Command(
77-
name=inspect.currentframe().f_code.co_name, # type: ignore
72+
name=inspect.currentframe().f_code.co_name, # type: ignore
7873
help=help,
7974
callback=callback,
80-
params=options # type: ignore
81-
)
75+
params=options, # type: ignore
76+
)

src/utils/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from os import system, name
2+
from time import sleep
3+
4+
5+
def clear(t: float) -> None:
6+
sleep(t)
7+
system("cls" if name == "nt" else "clear")

0 commit comments

Comments
 (0)