Skip to content

Commit

Permalink
v0.5.0: bump version and update docs
Browse files Browse the repository at this point in the history
This commit also sneaks in a few doc tests to catch documentation issues
a bit faster and directly fixes some minor issues.
  • Loading branch information
isd-project committed Feb 17, 2025
1 parent 6f632f9 commit 973fe5d
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 74 deletions.
7 changes: 4 additions & 3 deletions demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Set FontSize 16
Set Width 1280
Set Height 720

Type@10ms "systemctl start --user '0-isd-example-unit-01.service' '0-isd-example-unit-03.service'" Enter
# Should first run `./result/bin/generate-doc-test-data`.
Type@10ms "systemctl start --user '0-isd-example-unit-01.service' '0-isd-example-unit-05.service'" Enter
# do not full refresh during recording -> Set it to a very large value
# normal refresh should use the default value!
Type@10ms "ISD_CACHE_INPUT=false ISD_STARTUP_MODE=user ISD_JOURNAL_PAGER=lnav ISD_DEFAULT_PAGER=moar ISD_PREVIEW_AND_SELECTION_REFRESH_INTERVAL_SEC=2.5 ISD_FULL_REFRESH_INTERVAL_SEC=1000 asciinema rec --overwrite --quiet --command isd ./docs/assets/images/isd.cast"
Expand All @@ -92,7 +93,7 @@ Type "0-isd exmpl u 0"
Sleep 2s Type "]"

Tab
Sleep 2s Space Down Down
Sleep 2s Space Down@750ms 4
# Multi-selection marker
Sleep 1s Type "]" Sleep 1s

Expand Down Expand Up @@ -123,7 +124,7 @@ Type "q"
Sleep 2s

# show journal preview marker
Tab Sleep 0.5s Right
Tab Sleep 0.5s Tab Sleep 0.5s Right
Sleep 3s Type "]"
Sleep 1s Ctrl+p Type "open pag" Sleep 1.5s
Enter
Expand Down
27 changes: 20 additions & 7 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Just jump to the sections that sound interesting:
- [Journal Pager](#journal-pager)
- [Journal Pager Arguments](#journal-pager-arguments)
- [Theme](#theme)
- [Layout](#layout)
- [Keybindings](#keybindings)
- [Generic Keybindings](#generic-keybindings)
- [Main Keybindings](#main-keybindings)
Expand Down Expand Up @@ -179,6 +180,18 @@ But to persist the changes you _must_ update the configuration file.
<!-- [ansi escape codes](https://github.com/tinted-theming/home) -->
<!-- you -->

### Layout

`isd` allows you to customize the layout.
Currently, the relative heights between the search results and preview widgets
can be adjusted:

{{ config_block(11) }}

{{ config_block(12) }}

By default the preview widget is about twice as tall as the search results widget.

### Keybindings

> With great flexibility comes great responsibility.
Expand Down Expand Up @@ -208,25 +221,25 @@ for keybindings:

#### Generic Keybindings

{{ config_block(11) }}
{{ config_block(13) }}

See [Keybindings](#keybindings) for more general information.

#### Main Keybindings

{{ config_block(12) }}
{{ config_block(14) }}

See [Keybindings](#keybindings) for more general information.

#### Navigation Keybindings

{{ config_block(13) }}
{{ config_block(15) }}

See [Keybindings](#keybindings) for more general information.

#### `systemctl` Keybindings

{{ config_block(14) }}
{{ config_block(16) }}

This allows you to configure the `systemctl` commands and keybindings.
It is important to note that the `command` key may contain spaces (like `edit --runtime`)
Expand All @@ -250,21 +263,21 @@ the [shell injection section](security.md/#shell-injection).

### Pager Arguments

{{ config_block(15) }}
{{ config_block(17) }}

If you have to customize the pager arguments for a common pager,
please open an issue!

### Journal Pager Arguments

{{ config_block(16) }}
{{ config_block(18) }}

If you have to customize the pager arguments for a common pager,
please open an issue!

### Maximum Preview Lines

{{ config_block(17) }}
{{ config_block(19) }}

This value can mainly be configured if opening the journal preview
window takes too long. Though, it should usually not be required
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Limiting the functionality of the preview window is an explicit design decision
`isd` should be seen as the gateway to interact and work with `systemd` units while
seamlessly integrating with other, purpose-built tools.
By integrating with other tools, `isd` limits the scope of the application
(reducing feature creep) and gives users full control since it is easy to configure
(reducing feature creep), and gives you, the user, full control since it is easy to configure
your favorite pager/editor.

The main _goal_ of the preview window is to give quick feedback about the selected/highlighted
Expand Down
128 changes: 71 additions & 57 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,40 @@
pkgs = pkgsFor.${system};
pythonSet = pythonSet313For.${system};
version = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).project.version;
gen_unit =
name:
inputs.systemd-nix.lib.${system}.mkUserService name {
description = name;
documentation = [ "man:python" ];
wants = [ "default.target" ];
after = [ "default.target" ];
serviceConfig = {
Type = "simple"; # or oneshot for multiple ExecStart
# ExecStart = "${lib.getExe' pkgs.coreutils "sleep"} 1m";
ExecStart = "${lib.getExe pythonSet.python} ${./docs/loggen.py} 100";
# --number <number-of-messages>
# --interval <number of seconds loggen will run>
# --rate message per second
RemainAfterExit = true;
};
};
gen_broken_unit =
name:
inputs.systemd-nix.lib.${system}.mkUserService name {
description = name;
documentation = [ "man:python" ];
wants = [ "default.target" ];
after = [ "default.target" ];
serviceConfig = {
Type = "simple"; # or oneshot for multiple ExecStart
# ExecStart = "${lib.getExe' pkgs.coreutils "sleep"} 1m";
ExecStart = "${lib.getExe pythonSet.python} -asdf";
# --number <number-of-messages>
# --interval <number of seconds loggen will run>
# --rate message per second
RemainAfterExit = true;
};
};
in
rec {
default =
Expand Down Expand Up @@ -245,65 +279,45 @@
};
};

generate-integration-test-data =
let
gen_unit =
name:
inputs.systemd-nix.lib.${system}.mkUserService name {
description = name;
documentation = [ "man:python" ];
wants = [ "default.target" ];
after = [ "default.target" ];
serviceConfig = {
Type = "simple"; # or oneshot for multiple ExecStart
# ExecStart = "${lib.getExe' pkgs.coreutils "sleep"} 1m";
ExecStart = "${lib.getExe pythonSet.python} ${./docs/loggen.py} 100";
# --number <number-of-messages>
# --interval <number of seconds loggen will run>
# --rate message per second
RemainAfterExit = true;
};
};
gen_broken_unit =
name:
inputs.systemd-nix.lib.${system}.mkUserService name {
description = name;
documentation = [ "man:python" ];
wants = [ "default.target" ];
after = [ "default.target" ];
serviceConfig = {
Type = "simple"; # or oneshot for multiple ExecStart
# ExecStart = "${lib.getExe' pkgs.coreutils "sleep"} 1m";
ExecStart = "${lib.getExe pythonSet.python} -asdf";
# --number <number-of-messages>
# --interval <number of seconds loggen will run>
# --rate message per second
RemainAfterExit = true;
};
};
in
pkgs.writeScriptBin "generate-integration-test-data" ''
set -e
${lib.getExe (gen_unit "0-isd-example-unit-01")}
${lib.getExe (gen_unit "0-isd-example-unit-02")}
${lib.getExe (gen_unit "0-isd-example-unit-03")}
${lib.getExe (gen_broken_unit "0-isd-example-unit-04")}
generate-integration-test-data = pkgs.writeScriptBin "generate-integration-test-data" ''
set -e
${lib.getExe (gen_unit "0-isd-example-unit-01")}
${lib.getExe (gen_unit "0-isd-example-unit-02")}
${lib.getExe (gen_unit "0-isd-example-unit-03")}
${lib.getExe (gen_broken_unit "0-isd-example-unit-04")}
systemctl --user stop "0-isd-example-unit-02.service"
systemctl --user stop "0-isd-example-unit-03.service"
ln -s /tmp/__wrong_path_that_does_not_exist --force "$HOME/.config/systemd/user/0-isd-example-unit-03.service"
# 4 is broken by default
systemctl --user daemon-reload
systemctl --user stop "0-isd-example-unit-02.service"
systemctl --user stop "0-isd-example-unit-03.service"
ln -s /tmp/__wrong_path_that_does_not_exist --force "$HOME/.config/systemd/user/0-isd-example-unit-03.service"
# 4 is broken by default
systemctl --user daemon-reload
# Now generate the sample data from the above generated state.
export _SYSTEMD_USER_MODE=1
export OUT_DIR="$(git rev-parse --show-toplevel)/tests/integration-test/"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_list_data "0-isd*"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-01.service"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-02.service"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-03.service"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-04.service"
'';
# Now generate the sample data from the above generated state.
export _SYSTEMD_USER_MODE=1
export OUT_DIR="$(git rev-parse --show-toplevel)/tests/integration-test/"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_list_data "0-isd*"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-01.service"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-02.service"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-03.service"
${lib.getExe pkgs.bash} ${./tests/test_data_generator.sh} generate_unit_data "0-isd-example-unit-04.service"
'';

generate-doc-test-data = pkgs.writeScriptBin "generate-doc-test-data" ''
set -e
${lib.getExe (gen_unit "0-isd-example-unit-01")}
${lib.getExe (gen_unit "0-isd-example-unit-02")}
${lib.getExe (gen_unit "0-isd-example-unit-03")}
${lib.getExe (gen_broken_unit "0-isd-example-unit-04")}
${lib.getExe (gen_unit "0-isd-example-unit-05")}
${lib.getExe (gen_unit "0-isd-example-unit-06")}
${lib.getExe (gen_unit "0-isd-example-unit-07")}
systemctl --user stop "0-isd-example-unit-02.service"
systemctl --user stop "0-isd-example-unit-03.service"
ln -s /tmp/__wrong_path_that_does_not_exist --force "$HOME/.config/systemd/user/0-isd-example-unit-03.service"
# 4 is broken by default
systemctl --user daemon-reload
'';
}
);

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"pydantic>=2.10.4",
"types-pyyaml>=6.0.12.20241221",
]
version = "0.4.1"
version = "0.5.0"

# # versioningit was great in theory
# # but it comes with too many issues for packaging
Expand Down Expand Up @@ -97,7 +97,7 @@ exclude = [
"share/" = "share/"

[tool.bumpversion]
current_version = "0.4.1"
current_version = "0.5.0"
parse = """
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
Expand Down
12 changes: 8 additions & 4 deletions src/isd_tui/isd.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,12 @@ class Settings(BaseSettings):
default=Theme("textual-dark"), description="The theme of the application."
)

search_results_height_fraction: PositiveInt = 1
preview_height_fraction: PositiveInt = 2
search_results_height_fraction: PositiveInt = Field(
default=1, description="Relative height compared to preview height."
)
preview_height_fraction: PositiveInt = Field(
default=2, description="Relative height compared to search result height."
)

# FUTURE: Allow option to select if multi-select is allowed or not.
generic_keybindings: GenericKeybinding = Field(
Expand Down Expand Up @@ -916,7 +920,7 @@ def check_keybinding_overlaps(self) -> Self:


def get_default_settings() -> Settings:
return Settings.construct()
return Settings.model_construct()


def get_default_settings_yaml(as_comments: bool) -> str:
Expand Down Expand Up @@ -2520,6 +2524,7 @@ def __init__(
super().__init__(*args, **kwargs)
if force_defaults:
self.settings = Settings.model_construct()
self.settings.cache_input = False
self.settings_error = None
else:
try:
Expand All @@ -2541,7 +2546,6 @@ def __init__(
try:
_persistent_data["startup_count"] = self.startup_count
_persistent_json_fp.write_text(json.dumps(_persistent_data))
print("Written to ", _persistent_json_fp)
except Exception as e:
print(e)
else:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from isd_tui.isd import render_model_as_yaml, get_default_settings
from rich.traceback import install

install(show_locals=True)


def test_render_model():
render_model_as_yaml(get_default_settings())

0 comments on commit 973fe5d

Please sign in to comment.