4949 # # * lastUsed - the time when the command was recently excute
5050 # # * amount - how many times the user executed the command
5151 # # * path - the full path in which the command was executed
52- command* : string
52+ command: CommandName
5353 lastUsed: DateTime
54- amount: int
54+ amount: int32
5555 path: Path
5656
57+ proc command * (entry: HistoryEntry ): CommandName {.sideEffect , raises : [], tags : [],
58+ contractual .} =
59+ # # The getter of a field of HistoryEntry type
60+ # #
61+ # # * entry - the HistoryEntry object which field will be get
62+ # #
63+ # # Returns the value of the selected field
64+ entry.command
65+
5766using
5867 db: DbConn # Connection to the shell's database
5968 arguments: UserInput # The arguments for a command entered by the user
@@ -78,7 +87,7 @@ proc historyLength*(db): HistoryRange {.sideEffect, raises: [], tags: [
7887 return HistoryRange .low
7988
8089proc newHistoryEntry (command: CommandName = " " ; lastUsed: DateTime = now ();
81- amount: Positive = 1 ; path: Path = " " .Path ): HistoryEntry {.raises : [],
90+ amount: int32 = 1 ; path: Path = " " .Path ): HistoryEntry {.raises : [],
8291 tags : [], contractual .} =
8392 # # Create a new data structure for the shell's commands' history entry.
8493 # #
@@ -182,7 +191,7 @@ proc getHistory*(historyIndex: HistoryRange; db;
182191 body:
183192 try :
184193 type LocalEntry = ref object
185- command: string
194+ command: CommandName
186195 var entry: LocalEntry = LocalEntry ()
187196 # Get the command based on the historyIndex parameter
188197 if searchFor.len == 0 :
@@ -294,9 +303,9 @@ proc showHistory(db; arguments): ResultCode {.sideEffect, raises: [],
294303 e = getCurrentException (), db = db)
295304 try :
296305 type LocalEntry = ref object
297- command: string
306+ command: CommandName
298307 lastUsed: DateTime
299- amount: int
308+ amount: int32
300309 var entries: seq [LocalEntry ] = @ [LocalEntry ()]
301310 db.rawSelect (qry = " SELECT command, lastused, amount FROM history ORDER BY " &
302311 historyOrder & " LIMIT 0, ?" , objs = entries, params = amount)
@@ -347,7 +356,7 @@ proc findInHistory(db; arguments): ResultCode {.raises: [], tags: [
347356 db = db)).parseInt
348357 var currentRow: Natural = 0
349358 type LocalEntry = ref object
350- command: string
359+ command: CommandName
351360 var entries: seq [LocalEntry ] = @ [LocalEntry ()]
352361 db.rawSelect (qry = " SELECT command FROM history WHERE command LIKE ? ORDER BY lastused DESC, amount DESC" ,
353362 objs = entries, params = " %" & searchFor & " %" )
0 commit comments