Skip to content

Commit 31053d2

Browse files
tmgbeduclaude
andauthored
feat: update console-app example (#73)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 124bde6 commit 31053d2

4 files changed

Lines changed: 22 additions & 30 deletions

File tree

example/console-app/bootstrap/application.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@
66

77
app: Application = Application(
88
base_path=Path(__file__).resolve().parent.parent,
9-
providers=[
10-
LogProvider,
11-
ConsoleServiceProvider
12-
]
9+
providers=[LogProvider, ConsoleServiceProvider],
1310
)

example/console-app/commands/example_command.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55

66

77
class ExampleCommand(Command):
8-
name ="hello"
8+
name = "hello"
99
description = "This command greet the users."
1010

1111
arguments = [
12-
argument(
13-
"name",
14-
description="Who do you want to greet?",
15-
optional=True
16-
)
12+
argument("name", description="Who do you want to greet?", optional=True)
1713
]
1814

1915
def handle(self):
20-
name = self.argument('name')
16+
name = self.argument("name")
2117
if name:
22-
text = 'Hello {}'.format(name)
18+
text = "Hello {}".format(name)
2319
else:
24-
text = 'Hello'
20+
text = "Hello"
2521

2622
# Example of showing loggings
2723
Logger.info(text)

example/console-app/config/logging.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66

77
@dataclasses.dataclass
88
class LoggingConfig:
9-
default: str = dataclasses.field(default_factory=lambda: env('LOG_CHANNEL', 'stack'))
9+
default: str = dataclasses.field(
10+
default_factory=lambda: env("LOG_CHANNEL", "stack")
11+
)
1012

11-
channels: dict = dataclasses.field(default_factory=lambda: {
12-
'stack': StackChannel(
13-
driver='stack',
14-
channels=['daily', 'terminal']
15-
),
16-
'daily': DailyChannel(
17-
level=env('LOG_DAILY_LEVEL', 'debug'),
18-
path=env('LOG_DAILY_PATH', 'storage/logs'),
19-
),
20-
'terminal': TerminalChannel(
21-
level=env('LOG_TERMINAL_LEVEL', 'info'),
22-
),
23-
})
13+
channels: dict = dataclasses.field(
14+
default_factory=lambda: {
15+
"stack": StackChannel(driver="stack", channels=["daily", "terminal"]),
16+
"daily": DailyChannel(
17+
level=env("LOG_DAILY_LEVEL", "debug"),
18+
path=env("LOG_DAILY_PATH", "storage/logs"),
19+
),
20+
"terminal": TerminalChannel(
21+
level=env("LOG_TERMINAL_LEVEL", "info"),
22+
),
23+
}
24+
)

example/console-app/providers/console.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ def register(self):
77
pass
88

99
def boot(self):
10-
self.app.add_commands([
11-
ExampleCommand
12-
])
10+
self.app.add_commands([ExampleCommand])

0 commit comments

Comments
 (0)