Skip to content

Commit

Permalink
feat: when command variable show was executed without entering a vari…
Browse files Browse the repository at this point in the history
…able id, show the list of available environment variables to select

FossilOrigin-Name: 1a708999c7b9087676c0eadace0c24605bb2089d5de015ec35e7d0b39bf08b74
  • Loading branch information
thindil committed Jan 14, 2024
1 parent 174de4c commit 3d4fe45
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/variables.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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: ",
Expand Down

0 comments on commit 3d4fe45

Please sign in to comment.