Skip to content

Commit

Permalink
autoload gdbdash config if it exists in the current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
JensDll committed Aug 1, 2023
1 parent 301b953 commit b39b04b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions unix/.config/gdbdash/gdbdash/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import itertools
import json
import pathlib
from functools import cached_property, partial
from inspect import isclass
from os import get_terminal_size
Expand Down Expand Up @@ -35,6 +36,9 @@ def __init__(self):
command_prefix=True,
)

self.config_path = pathlib.Path.cwd() / "gdbdash.config.json"
self.config_modified_time = 0

self.module_types = [
value
for value in vars(gdbdash.modules).values()
Expand Down Expand Up @@ -70,6 +74,8 @@ def render(self):
width = 160
height = 24

self.try_load_config()

def render_file(
output, modules
): # type: (FileDescriptorOrPath, Iterator[gdbdash.modules.Module]) -> None
Expand Down Expand Up @@ -174,6 +180,13 @@ def load(self, path):
for option_name, option in json_module["options"].items():
module.options[option_name].value = option

def try_load_config(self):
if self.config_path.is_file():
config_modified_time = self.config_path.stat().st_mtime
if config_modified_time > self.config_modified_time:
self.config_modified_time = config_modified_time
self.load(self.config_path)

@cached_property
def options(self): # type: () -> DashboardOptions
return {
Expand Down
1 change: 1 addition & 0 deletions unix/.gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set print array-indexes on
set python print-stack full

define cls
dont-repeat
shell clear
end
document cls
Expand Down

0 comments on commit b39b04b

Please sign in to comment.