New global option to adapt output format
[osm/osmclient.git] / osmclient / scripts / osm.py
index e5be118..0a17948 100755 (executable)
@@ -41,9 +41,8 @@ from osmclient.cli_commands import (
     wim,
 )
 import yaml
-import pycurl
-import os
 import logging
+from requests import RequestException
 
 
 @click.group(
@@ -79,6 +78,11 @@ import logging
     count=True,
     help="increase verbosity (-v INFO, -vv VERBOSE, -vvv DEBUG)",
 )
+@click.option(
+    "-o",
+    "--output",
+    help="adapt output format (table, yaml, csv, json, jsonpath)",
+)
 @click.option("--all-projects", default=None, is_flag=True, help="include all projects")
 @click.option(
     "--public/--no-public",
@@ -115,8 +119,7 @@ def cli_osm(ctx, **kwargs):
         exit(1)
     # Remove None values
     kwargs = {k: v for k, v in kwargs.items() if v is not None}
-    sol005 = os.getenv("OSM_SOL005", True)
-    ctx.obj = client.Client(host=hostname, sol005=sol005, **kwargs)
+    ctx.obj = client.Client(version=1, host=hostname, **kwargs)
     logger = logging.getLogger("osmclient")
 
 
@@ -292,7 +295,7 @@ def cli():
 
         cli_osm()
         exit(0)
-    except pycurl.error as exc:
+    except RequestException as exc:
         print(exc)
         print(
             'Maybe "--hostname" option or OSM_HOSTNAME environment variable needs to be specified'