Add trace_export_script/src/trace_export_script/cli.py
This commit is contained in:
parent
d90f215d65
commit
8bb57d5f5b
1 changed files with 24 additions and 0 deletions
24
trace_export_script/src/trace_export_script/cli.py
Normal file
24
trace_export_script/src/trace_export_script/cli.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
from trace_export_script.core import export_trace_data
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Exportiert Trace-Daten in JSON oder CSV.")
|
||||||
|
parser.add_argument("--input", required=True, help="Pfad zur Eingabedatei mit Trace-Daten im JSON-Format.")
|
||||||
|
parser.add_argument("--format", required=True, choices=["json", "csv"], help="Zielformat des Exports (csv oder json).")
|
||||||
|
parser.add_argument("--output", required=False, help="Pfad zur Ausgabe-Datei (Standard: output/exported_trace.<format>).")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
input_path = args.input
|
||||||
|
export_format = args.format.lower()
|
||||||
|
output_path = args.output or os.path.join("output", f"exported_trace.{export_format}")
|
||||||
|
|
||||||
|
if not os.path.isfile(input_path):
|
||||||
|
raise FileNotFoundError(f"Eingabedatei nicht gefunden: {input_path}")
|
||||||
|
|
||||||
|
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
||||||
|
|
||||||
|
export_trace_data(file_path=input_path, format=export_format)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in a new issue