Skip to content

Commit 5940476

Browse files
committed
cli check version
1 parent adbf29f commit 5940476

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lfss/api/connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def version(self) -> str:
158158
To get the client version, use `lfss.__version__`.
159159
"""
160160
response = self._fetch_factory('GET', '_api/version')()
161-
return response.text.strip()
161+
return response.json()
162162

163163
def exists(self, path: str) -> bool:
164164
"""Checks if a file/directory exists."""

lfss/cli/cli.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
22
import argparse, typing, sys
3+
4+
from lfss import __version__
35
from lfss.api import Client, upload_directory, upload_file, download_file, download_directory
46
from lfss.eng.datatype import (
57
FileReadPermission, AccessLevel,
@@ -75,7 +77,11 @@ def print_ln(r: DirectoryRecord | FileRecord):
7577
print_ln(f)
7678

7779
def parse_arguments():
78-
parser = argparse.ArgumentParser(description="Client-side command line interface, set LFSS_ENDPOINT and LFSS_TOKEN environment variables for authentication.")
80+
parser = argparse.ArgumentParser(
81+
description = f"Client-side command line interface (v{__version__}). \n"
82+
"Set LFSS_ENDPOINT and LFSS_TOKEN environment variables for authentication.",
83+
formatter_class=argparse.RawTextHelpFormatter
84+
)
7985

8086
sp = parser.add_subparsers(dest="command", required=True)
8187

@@ -166,6 +172,10 @@ def parse_arguments():
166172
sp_show = sp.add_parser("concatenate", help="Concatenate and print files", aliases=["cat"])
167173
sp_show.add_argument("path", help="Path to the text files", type=str, nargs="+")
168174
sp_show.add_argument("-e", "--encoding", type=str, default="utf-8", help="Text file encoding, default utf-8")
175+
176+
# check server version
177+
sp_version = sp.add_parser("version", help="Show server version")
178+
169179
return parser.parse_args()
170180

171181
def main():
@@ -361,6 +371,12 @@ def main():
361371
except (FileNotFoundError, ValueError) as e:
362372
print(f"\033[31m{e}\033[0m", file=sys.stderr)
363373

374+
elif args.command == "version":
375+
with catch_request_error():
376+
server_version = connector.version()
377+
print(f"Client version: {__version__}")
378+
print(f"Server version: {server_version}")
379+
364380
else:
365381
raise NotImplementedError(f"Command {args.command} not implemented.")
366382

0 commit comments

Comments
 (0)