From 3d4fe4521418adf6373835bafd448e668ab205fa Mon Sep 17 00:00:00 2001 From: thindil Date: Sun, 14 Jan 2024 05:19:06 +0000 Subject: [PATCH] feat: when command variable show was executed without entering a variable id, show the list of available environment variables to select FossilOrigin-Name: 1a708999c7b9087676c0eadace0c24605bb2089d5de015ec35e7d0b39bf08b74 --- src/variables.nim | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/variables.nim b/src/variables.nim index 32e8093b..0ac80678 100644 --- a/src/variables.nim +++ b/src/variables.nim @@ -730,17 +730,11 @@ proc showVariable*(arguments; db): ResultCode {.sideEffect, raises: [], tags: [ arguments.startsWith(prefix = "show") db != nil body: - if arguments.len < 6: - return showError(message = "Enter the ID of the variable to show.", db = db) - let id: DatabaseId = try: - parseInt(s = $arguments[5 .. ^1]).DatabaseId - except: - return showError(message = "The Id of the variable must be a positive number.", db = db) + let id: DatabaseId = getVariableId(arguments = arguments, db = db) + if id.Natural == 0: + return QuitFailure.ResultCode var variable: Variable = newVariable() try: - if not db.exists(T = Variable, cond = "id=?", params = $id): - return showError(message = "The variable with the ID: " & $id & - " doesn't exists.", db = db) db.select(obj = variable, cond = "id=?", params = $id) except: return showError(message = "Can't read variable data from database. Reason: ",