-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (39 loc) · 1.26 KB
/
main.py
File metadata and controls
51 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import typer
from typing import Optional, List
from rich.console import Console
from commands.info import show_info
from commands.pods import monitor_pods
from flags.kubeconfig import get_kubeconfig_option
from flags.namespace import get_namespace_option, process_namespaces
app = typer.Typer(
name="kai",
help="Kubernetes Monitor CLI",
add_completion=True,
)
console = Console()
@app.command("info")
def info_command():
show_info()
@app.command("pods")
def pods_command(
kubeconfig: Optional[str] = get_kubeconfig_option(),
namespace: Optional[List[str]] = get_namespace_option()
):
unique_namespaces = process_namespaces(namespace)
console.print(f"[bold]Monitoring namespaces:[/bold] {', '.join(unique_namespaces)}")
monitor_pods(kubeconfig=kubeconfig, namespaces=unique_namespaces)
@app.callback(invoke_without_command=True)
def main(
ctx: typer.Context
):
if ctx.invoked_subcommand is None:
console.print(
"[bold green]Kubernetes Monitor CLI[/bold green] - "
"[italic]Version 0.0.2[/italic]\n"
"\n"
"Run 'kai info' to get more information about the tool.\n"
"\n"
"Run 'kai --help' for usage information.\n"
)
if __name__ == "__main__":
app()