From 0941073a68d4181a80a79291cac07a1d4fdfdb59 Mon Sep 17 00:00:00 2001 From: thindil Date: Sat, 2 Nov 2024 05:32:14 +0000 Subject: [PATCH] chore: fixed some issues reported by nimalyzer FossilOrigin-Name: 71b7dd99c9858e6dfb97745a9504415b87c91e68dde30f6c845406ab73ef0dd0 --- src/output.nim | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/output.nim b/src/output.nim index fc3d6ae3..b91b1617 100644 --- a/src/output.nim +++ b/src/output.nim @@ -129,9 +129,17 @@ proc showFormHeader*(message; width: ColumnAmount = (try: terminalWidth( db != nil body: type LocalOption = ref object - value: string + value: OptionValue + proc initLocalOption(value: OptionValue = ""): LocalOption {.raises: [], + tags: [], contractual.} = + ## Initialize a new instance of LocalOptions object + ## + ## * value - the value of the option. Can be empty. Default value is empty + ## + ## Returns the new instance of LocalOption object + result = LocalOption(value: value) try: - var option: LocalOption = LocalOption() + var option: LocalOption = initLocalOption() db.rawSelect(qry = "SELECT value FROM options WHERE option='outputHeaders'", obj = option) let headerType: DbString = option.value if headerType == "hidden": @@ -190,7 +198,8 @@ proc showFormHeader*(message; width: ColumnAmount = (try: terminalWidth( e = getCurrentException(), db = db) proc selectOption*(options: Table[char, string]; - default: char; prompt: OutputMessage; db): char {.sideEffect, raises: [], tags: [ReadIOEffect, + default: char; prompt: OutputMessage; db): char {.sideEffect, raises: [], + tags: [ReadIOEffect, WriteIOEffect, RootEffect], contractual.} = ## Show the list of options from which the user can select one value ## @@ -250,8 +259,8 @@ proc confirm*(prompt: OutputMessage; db): bool {.sideEffect, raises: [], tags: [ discard return inputChar in {'y', 'Y'} -proc showFormPrompt*(prompt: OutputMessage; db) {.sideEffect, raises: [], tags: [ - ReadIOEffect, WriteIOEffect, RootEffect], contractual.} = +proc showFormPrompt*(prompt: OutputMessage; db) {.sideEffect, raises: [], + tags: [ReadIOEffect, WriteIOEffect, RootEffect], contractual.} = ## Show the prompt in the shell's forms ## ## * prompt - the text displayed as a form's prompt