From 82bb71a35a42cda1ea59e84af1aa457e5ab41ec1 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Wed, 6 Apr 2022 14:55:46 +0200 Subject: [PATCH] parse arguments --- README.md | 6 +++++- main.py | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 135d430..94d067c 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,12 @@ ## Usage +usage: `./main.py []` + +Example: + ```bash -(venv-310) [user@linux snoflake-stats]$ ./main.py +(venv-310) [user@linux snoflake-stats]$ ./main.py snowflake-proxy root_at_my_server ``` ## Example output diff --git a/main.py b/main.py index 2826b16..9eff0c6 100755 --- a/main.py +++ b/main.py @@ -2,12 +2,23 @@ from __future__ import annotations from typing import List from datetime import datetime +import sys import exec def main(): - log: str = docker_logs(container_name='snowflake-proxy', ssh_host='rootnas') + if len(sys.argv) < 2: + print(f'usage: {sys.argv[0]} []', file=sys.stderr) + exit(1) + + container_name = sys.argv[1] + + ssh_hostname = None + if len(sys.argv) > 2: + ssh_hostname = sys.argv[2] + + log: str = docker_logs(container_name, ssh_hostname) filtered: List[str] = [line for line in log.splitlines() if Throughput.PATTERN in line] # filtered = filtered_example()