diff options
author | Yuchen Pei <hi@ypei.me> | 2022-10-05 12:23:22 +1100 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-10-05 12:23:22 +1100 |
commit | c996eaabb66e2ca4b1b9e16c65dc1d063f96383a (patch) | |
tree | bfb75166f89ab263ca30657eff78b8284d467303 | |
parent | c4403522df754627d698f0806d3920764e3d1291 (diff) |
Adding version checkapi-global-identifier
-rw-r--r-- | hcel-client.el | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/hcel-client.el b/hcel-client.el index fef8bf6..d88a6a1 100644 --- a/hcel-client.el +++ b/hcel-client.el @@ -27,6 +27,29 @@ :group 'hcel :type '(string)) (defvar hcel-client-buffer-name "*hcel-client*") +(defvar hcel-server-version "0.1.0.0" + "The version of hcel the server we are talking to.") + +(defun hcel-fetch-server-version () + (interactive) + (setq hcel-server-version + (condition-case nil + (hcel-url-fetch-json + (concat hcel-host "/api/greet")) + (error "0.1.0.0")))) + +(hcel-fetch-server-version) + +(defun hcel-require-server-version (lower-bound higher-bound) + (unless (and (or (not lower-bound) + (string< lower-bound hcel-server-version) + (equal lower-bound hcel-server-version)) + (or (not higher-bound) + (string> higher-bound hcel-server-version) + (equal higher-bound hcel-server-version))) + (error + "Server version cannot be satisfied. Actual version: %s. Required version: lower bound - %s, higher bound - %s" + hcel-server-version lower-bound higher-bound))) (defun hcel-api-packages () (let ((packages @@ -161,6 +184,7 @@ Example of approximate location: (defun hcel-api-global-identifier-a (package-id component-id module-name entity name) + (hcel-require-server-version "1.0.0" nil) (hcel-url-fetch-json (concat hcel-host "/api/globalIdentifierA/" (hcel-format-package-id package-id "-") "/" component-id "/" @@ -168,6 +192,7 @@ Example of approximate location: (defun hcel-api-global-identifier-e (package-id module-path start-line start-column end-line end-column name) + (hcel-require-server-version "1.0.0" nil) (hcel-url-fetch-json (concat hcel-host "/api/globalIdentifierE/" (hcel-format-package-id package-id "-") "/" |