Skip to content

Commit

Permalink
feat: started work on ability to set executing commands with or witho…
Browse files Browse the repository at this point in the history
…ut the default shell

FossilOrigin-Name: a20c571862fcf11490ec2d710c8017ff5b22042ef26acbad8cfe52e389e689d3
  • Loading branch information
thindil committed Jan 2, 2024
1 parent 9b7e7e7 commit 36664ce
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/db.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2023 Bartek Jasicki
# Copyright © 2023-2024 Bartek Jasicki
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -91,7 +91,7 @@ proc startDb*(dbPath: DirectoryPath): DbConn {.sideEffect, raises: [], tags: [
showError(message = "Can't open the shell's database. Reason: ",
e = getCurrentException(), db = nil)
return nil
let options: array[11, Option] = [newOption(name = "dbVersion", value = "6",
let options: array[12, Option] = [newOption(name = "dbVersion", value = "6",
description = "Version of the database schema (read only).",
valueType = OptionValType.natural, readOnly = true, defaultValue = "6"),
newOption(name = "promptCommand", value = "built-in",
Expand Down Expand Up @@ -124,7 +124,10 @@ proc startDb*(dbPath: DirectoryPath): DbConn {.sideEffect, raises: [], tags: [
valueType = OptionValType.natural, readOnly = false, defaultValue = "1"),
newOption(name = "titleWidth", value = "30",
description = "The maximum length of a terminal title which will be set.",
valueType = OptionValType.positive, readOnly = false, defaultValue = "30")]
valueType = OptionValType.positive, readOnly = false, defaultValue = "30"),
newOption(name = "execWithShell", value = "true",
description = "Execute all commands by using the system's default shell.",
valueType = OptionValType.boolean, readOnly = false, defaultValue = "true")]
# Create a new database if not exists
if not dbExists:
if result.createAliasesDb == QuitFailure:
Expand Down Expand Up @@ -220,7 +223,7 @@ proc startDb*(dbPath: DirectoryPath): DbConn {.sideEffect, raises: [], tags: [
return nil
if result.createThemeDb == QuitFailure:
return nil
for i in [0, 8, 9, 10]:
for i in [0, 8, 9, 10, 11]:
setOption(optionName = initLimitedString(capacity = 40,
text = options[i].option), value = initLimitedString(capacity = 40,
text = options[i].value), description = initLimitedString(
Expand All @@ -230,7 +233,7 @@ proc startDb*(dbPath: DirectoryPath): DbConn {.sideEffect, raises: [], tags: [
of 4:
if result.createCompletionDb == QuitFailure:
return nil
for i in [0, 10]:
for i in [0, 10, 11]:
setOption(optionName = initLimitedString(capacity = 40,
text = options[i].option), value = initLimitedString(capacity = 40,
text = options[i].value), description = initLimitedString(
Expand All @@ -242,12 +245,13 @@ proc startDb*(dbPath: DirectoryPath): DbConn {.sideEffect, raises: [], tags: [
return nil
if result.createThemeDb == QuitFailure:
return nil
setOption(optionName = initLimitedString(capacity = 40,
text = options[0].option), value = initLimitedString(capacity = 40,
text = options[0].value), description = initLimitedString(
capacity = 256, text = options[0].description),
valueType = options[0].valueType, db = result, readOnly = (
if options[0].readOnly: 1 else: 0))
for i in [0, 11]:
setOption(optionName = initLimitedString(capacity = 40,
text = options[i].option), value = initLimitedString(capacity = 40,
text = options[i].value), description = initLimitedString(
capacity = 256, text = options[i].description),
valueType = options[i].valueType, db = result, readOnly = (
if options[i].readOnly: 1 else: 0))
of 6:
discard
else:
Expand Down

0 comments on commit 36664ce

Please sign in to comment.