Skip to content

Commit

Permalink
fixed CKIT_HOME issue and added ckit gif
Browse files Browse the repository at this point in the history
  • Loading branch information
fpgmaas committed Dec 21, 2022
1 parent cc98c7e commit a6e3b2a
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For more information, see the [documentation](https://fpgmaas.github.io/ckit/).
_ckit_ can look for configuration in the following two locations:

- In a `ckit.yaml` file in the current directory
- In any `.yaml` file in the the global configuration directory, which is defaulted to `~/ckit`, but which can be overridden with the environment variable `ckit_HOME`.
- In any `.yaml` file in the the global configuration directory, which is defaulted to `~/ckit`, but which can be overridden with the environment variable `CKIT_HOME`.

An example `.yaml` file could look as follows:

Expand Down
3 changes: 2 additions & 1 deletion ckit/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dataclasses import dataclass

import click
import shlex


@dataclass
Expand Down Expand Up @@ -56,7 +57,7 @@ def run(self):
for command in cmd:
if self.echo:
click.echo(command)
subprocess.run(self._expand_env_vars(command).split(" "))
subprocess.run(shlex.split(self._expand_env_vars(command)))

@staticmethod
def _expand_env_vars(command):
Expand Down
2 changes: 1 addition & 1 deletion ckit/config/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ def get_global_commands_dir() -> Path:
"""
Get the directory that contains the global command .yaml files.
"""
home = Path(os.environ["ckit_HOME"]) if "ckit_HOME" in os.environ else Path.home() / "ckit"
home = Path(os.environ["CKIT_HOME"]) if "CKIT_HOME" in os.environ else Path.home() / "ckit"
return home
Binary file added docs/ckit.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_ckit_ looks for configuration in the following two locations

- From a `ckit.yaml` file in the current directory
- From any `.yaml` file in the the global configuration directory, which is defaulted to `~/ckit`, but which can be overridden with the environment variable `ckit_HOME`.
- From any `.yaml` file in the the global configuration directory, which is defaulted to `~/ckit`, but which can be overridden with the environment variable `CKIT_HOME`.

Each `.yaml` file can contain one or more command groups, each containg one or more commands

Expand Down
Binary file removed docs/skate.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/config/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@


def test_get_global_config_dir():
os.environ["ckit_HOME"] = "/some/dir"
os.environ["CKIT_HOME"] = "/some/dir"
assert get_global_commands_dir() == Path("/some/dir")
6 changes: 3 additions & 3 deletions tests/config/test_config_files_initiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ def test_config_files_initiator(mock_click, tmp_path: Path) -> None:
mock_click.return_value = "y"

with run_within_dir(tmp_path):
os.environ["ckit_HOME"] = str(tmp_path / "ckit_home")
os.environ["CKIT_HOME"] = str(tmp_path / "CKIT_HOME")
ConfigFilesInitiator().init()

assert "ckit.yaml" in os.listdir()
with open("ckit.yaml", "rb") as f:
command_groups_raw = yaml.load(f, Loader=yaml.loader.SafeLoader)
assert "example" in command_groups_raw

assert "ckit.yaml" in os.listdir("ckit_home")
with open("ckit_home/ckit.yaml", "rb") as f:
assert "ckit.yaml" in os.listdir("CKIT_HOME")
with open("CKIT_HOME/ckit.yaml", "rb") as f:
command_groups_raw = yaml.load(f, Loader=yaml.loader.SafeLoader)
assert "example" in command_groups_raw

0 comments on commit a6e3b2a

Please sign in to comment.