Skip to content

Commit

Permalink
feat: use the shell's theme's colors in aliases list command
Browse files Browse the repository at this point in the history
FossilOrigin-Name: f83ffd8ade20485241f5d095c18be24bf4ed0cfd3182a25312387b5a387ad75b
  • Loading branch information
thindil committed Dec 9, 2023
1 parent e10f1ab commit 8d51c5d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/aliases.nim
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ proc listAliases*(arguments; aliases; db): ResultCode {.sideEffect, raises: [],
body:
var table: TerminalTable = TerminalTable()
try:
table.add(parts = [magenta(ss = "ID"), magenta(ss = "Name"), magenta(
ss = "Description")])
let color: string = getColor(db = db, name = tableHeaders)
table.add(parts = [style(ss = "ID", style = color), style(ss = "Name",
style = color), style(ss = "Description", style = color)])
except:
return showError(message = "Can't show aliases list. Reason: ",
e = getCurrentException(), db = db)
Expand Down Expand Up @@ -170,8 +171,9 @@ proc listAliases*(arguments; aliases; db): ResultCode {.sideEffect, raises: [],
return QuitSuccess.ResultCode
try:
for dbResult in dbAliases:
table.add(parts = [yellow(ss = dbResult.id), green(ss = dbResult.name),
dbResult.description])
table.add(parts = [style(ss = dbResult.id, style = getColor(db = db,
name = ids)), style(ss = dbResult.name, style = getColor(db = db,
name = ids)), dbResult.description])
except:
return showError(message = "Can't add an alias to the list. Reason:",
e = getCurrentException(), db = db)
Expand Down Expand Up @@ -287,14 +289,15 @@ proc showAlias*(arguments; db): ResultCode {.sideEffect, raises: [], tags: [
e = getCurrentException(), db = db)
var table: TerminalTable = TerminalTable()
try:
table.add(parts = [magenta(ss = "Id:"), $id])
table.add(parts = [magenta(ss = "Name:"), alias.name])
table.add(parts = [magenta(ss = "Description:"), (
let color: string = getColor(db = db, name = showHeaders)
table.add(parts = [style(ss = "Id:", style = color), $id])
table.add(parts = [style(ss = "Name:", style = color), alias.name])
table.add(parts = [style(ss = "Description:", style = color), (
if alias.description.len > 0: alias.description else: "(none)")])
table.add(parts = [magenta(ss = "Path:"), alias.path & (
table.add(parts = [style(ss = "Path:", style = color), alias.path & (
if alias.recursive: " (recursive)" else: "")])
table.add(parts = [magenta(ss = "Command(s):"), alias.commands])
table.add(parts = [magenta(ss = "Output to:"), alias.output])
table.add(parts = [style(ss = "Command(s):", style = color), alias.commands])
table.add(parts = [style(ss = "Output to:", style = color), alias.output])
table.echoTable
except:
return showError(message = "Can't show alias. Reason: ",
Expand Down

0 comments on commit 8d51c5d

Please sign in to comment.