Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fpgmaas committed Dec 20, 2022
1 parent 29e8192 commit cc98c7e
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
docs/source
peaks.yaml
ckit.yaml

# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore

Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Types of Contributions
Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/fpgmaas/peaks/issues
Report bugs at https://github.com/fpgmaas/ckit/issues

If you are reporting a bug, please include:

Expand Down Expand Up @@ -44,7 +44,7 @@ Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at
https://github.com/fpgmaas/peaks/issues.
https://github.com/fpgmaas/ckit/issues.

If you are proposing a new feature:

Expand All @@ -56,25 +56,25 @@ If you are proposing a new feature:
Get Started!
------------

Ready to contribute? Here's how to set up `peaks` for local
Ready to contribute? Here's how to set up `ckit` for local
development. Please note this documentation assumes you already have
`poetry` and `Git` installed and ready to go.

| 1. Fork the `peaks` repo on GitHub.
| 1. Fork the `ckit` repo on GitHub.
| 2. Clone your fork locally:
.. code-block:: bash
cd <directory_in_which_repo_should_be_created>
git clone [email protected]:YOUR_NAME/peaks.git
git clone [email protected]:YOUR_NAME/ckit.git
| 3. Now we need to install the environment. Navigate into the directory
.. code-block:: bash
cd peaks
cd ckit
If you are using ``pyenv``, select a version to use locally. (See installed versions with ``pyenv versions``)

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ COPY poetry.lock pyproject.toml /code/
RUN poetry install --no-interaction --no-ansi --no-root --no-dev

# Copy Python code to the Docker image
COPY peaks /code/peaks/
COPY ckit /code/ckit/

CMD [ "python", "peaks/foo.py"]
CMD [ "python", "ckit/foo.py"]
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
<p align="center">
<h1>peaks</h1>
<h1>ckit</h1>
</p>

---

[![Release](https://img.shields.io/github/v/release/fpgmaas/peaks)](https://img.shields.io/github/v/release/fpgmaas/peaks)
[![Build status](https://img.shields.io/github/actions/workflow/status/fpgmaas/peaks/main.yml?branch=main)](https://github.com/fpgmaas/peaks/actions/workflows/main.yml?query=branch%3Amain)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/peaks)](https://pypi.org/project/peaks/)
[![codecov](https://codecov.io/gh/fpgmaas/peaks/branch/main/graph/badge.svg)](https://codecov.io/gh/fpgmaas/peaks)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/peaks)](https://pypistats.org/packages/peaks)
[![License](https://img.shields.io/github/license/fpgmaas/peaks)](https://img.shields.io/github/license/fpgmaas/peaks)
[![Release](https://img.shields.io/github/v/release/fpgmaas/ckit)](https://img.shields.io/github/v/release/fpgmaas/ckit)
[![Build status](https://img.shields.io/github/actions/workflow/status/fpgmaas/ckit/main.yml?branch=main)](https://github.com/fpgmaas/ckit/actions/workflows/main.yml?query=branch%3Amain)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/ckit)](https://pypi.org/project/ckit/)
[![codecov](https://codecov.io/gh/fpgmaas/ckit/branch/main/graph/badge.svg)](https://codecov.io/gh/fpgmaas/ckit)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/ckit)](https://pypistats.org/packages/ckit)
[![License](https://img.shields.io/github/license/fpgmaas/ckit)](https://img.shields.io/github/license/fpgmaas/ckit)

_peaks_ is a command line utility to help you organise and quickly run frequently used commands.
_ckit_ is a command line utility to help you organise and quickly run frequently used commands.

<p align="center">
<img src="docs/peaks.gif"/>
<img src="docs/ckit.gif"/>
</p>

## Quickstart

### Installation

_peaks_ can be installed by running
_ckit_ can be installed by running

```shell
pip install peaks
pip install ckit
```

To get started, run

```shell
peaks init
ckit init
```

which will prompt to add a `peaks/peaks.yaml` file in the user's home directory for global commands, and/or a `peaks.yaml` file in the current directory for commands specific to the current project.
which will prompt to add a `ckit/ckit.yaml` file in the user's home directory for global commands, and/or a `ckit.yaml` file in the current directory for commands specific to the current project.

To use _peaks_ to run any of the pre-configured commands, simply run
To use _ckit_ to run any of the pre-configured commands, simply run

```
peaks
ckit
```

For more information, see the [documentation](https://fpgmaas.github.io/peaks/).
For more information, see the [documentation](https://fpgmaas.github.io/ckit/).

## Configuration

_peaks_ can look for configuration in the following two locations:
_ckit_ can look for configuration in the following two locations:

- In a `peaks.yaml` file in the current directory
- In any `.yaml` file in the the global configuration directory, which is defaulted to `~/peaks`, but which can be overridden with the environment variable `peaks_HOME`.
- 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`.

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

Expand All @@ -62,9 +62,9 @@ test:
- fruit: apple
```
Which adds the command group `test` wth a single command called `my-command`. When `my-command` is selected to be run, _peaks_ prompts the user for `name` and `fruit` before running the command specified in `cmd`, where `fruit` is defaulted to `apple` if the user does not give any input.
Which adds the command group `test` wth a single command called `my-command`. When `my-command` is selected to be run, _ckit_ prompts the user for `name` and `fruit` before running the command specified in `cmd`, where `fruit` is defaulted to `apple` if the user does not give any input.

For more details, see the [configuration](https://fpgmaas.github.io/peaks/configuration) section of the documentation.
For more details, see the [configuration](https://fpgmaas.github.io/ckit/configuration) section of the documentation.

---

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions peaks/cli.py → ckit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import click

from peaks.config.config_files_initiatior import ConfigFilesInitiator
from peaks.config.config_loader import ConfigLoader
from peaks.core import Core
from ckit.config.config_files_initiatior import ConfigFilesInitiator
from ckit.config.config_loader import ConfigLoader
from ckit.core import Core


@click.group(invoke_without_command=True)
Expand All @@ -21,7 +21,7 @@
help="Boolean flag to only select a command from global files.",
)
@click.pass_context
def peaks(ctx, local_only: bool, global_only: bool) -> None:
def ckit(ctx, local_only: bool, global_only: bool) -> None:
if not ctx.invoked_subcommand:
if local_only and global_only:
raise ValueError(
Expand All @@ -32,6 +32,6 @@ def peaks(ctx, local_only: bool, global_only: bool) -> None:
Core(config).run()


@peaks.command()
@ckit.command()
def init():
ConfigFilesInitiator().init()
File renamed without changes.
2 changes: 1 addition & 1 deletion peaks/command_group.py → ckit/command_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass

from peaks.command import Command
from ckit.command import Command


@dataclass
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion peaks/config/common.py → 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["peaks_HOME"]) if "peaks_HOME" in os.environ else Path.home() / "peaks"
home = Path(os.environ["ckit_HOME"]) if "ckit_HOME" in os.environ else Path.home() / "ckit"
return home
2 changes: 1 addition & 1 deletion peaks/config/config.py → ckit/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dataclasses import dataclass

from peaks.command_group import CommandGroup
from ckit.command_group import CommandGroup


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import click

from peaks.config.common import get_global_commands_dir
from ckit.config.common import get_global_commands_dir

COMMANDS_YAML_DEFAULT = """example:
echo:
Expand Down Expand Up @@ -39,34 +39,34 @@
class ConfigFilesInitiator:
def init(self):
"""
Check for the existence of local- and global peaks.yaml files, and if they do not exist,
Check for the existence of local- and global ckit.yaml files, and if they do not exist,
ask the user if they should be created.
"""
self._init_global()
self._init_local()

def _init_local(self):
"""
Check if a peaks.yaml file exists in the current directory. Otherwise, ask the user
Check if a ckit.yaml file exists in the current directory. Otherwise, ask the user
if it needs to be created, and if so; created it.
"""
if Path("peaks.yaml").exists():
click.echo("A local peaks.yaml already exists.")
if Path("ckit.yaml").exists():
click.echo("A local ckit.yaml already exists.")
else:
if click.confirm("Create a peaks.yaml file in the current directory?", default=True):
with open("peaks.yaml", "w") as f:
if click.confirm("Create a ckit.yaml file in the current directory?", default=True):
with open("ckit.yaml", "w") as f:
f.write(COMMANDS_YAML_DEFAULT)

def _init_global(self):
"""
Check if there is a global peaks.yaml file. If it does not exist, ask the user if it should be created, and
Check if there is a global ckit.yaml file. If it does not exist, ask the user if it should be created, and
if so, create it.
"""
global_commands_file = get_global_commands_dir() / "peaks.yaml"
global_commands_file = get_global_commands_dir() / "ckit.yaml"
if global_commands_file.exists():
click.echo(f"{global_commands_file} already exists.")
else:
if click.confirm(f"Create a global peaks.yaml file in {global_commands_file.parent}?", default=True):
if click.confirm(f"Create a global ckit.yaml file in {global_commands_file.parent}?", default=True):
global_commands_file.parent.mkdir(parents=True, exist_ok=True)
with open(global_commands_file, "w") as f:
f.write(COMMANDS_YAML_DEFAULT)
12 changes: 6 additions & 6 deletions peaks/config/config_loader.py → ckit/config/config_loader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dataclasses import dataclass
from pathlib import Path

from peaks.config.common import get_global_commands_dir
from peaks.config.config import Config
from peaks.config.yaml_parser import YamlParser
from ckit.config.common import get_global_commands_dir
from ckit.config.config import Config
from ckit.config.yaml_parser import YamlParser


@dataclass
Expand All @@ -20,7 +20,7 @@ def load(self) -> Config:
global_command_groups = self._load_global() if self.load_global else None

if not local_command_groups and not global_command_groups:
exit("No configuration files were found. Did you initialize the application with `peaks init`?")
exit("No configuration files were found. Did you initialize the application with `ckit init`?")

return Config(local_command_groups=local_command_groups, global_command_groups=global_command_groups)

Expand All @@ -40,6 +40,6 @@ def _load_global(self):
return {}

def _load_local(self):
if Path("peaks.yaml").exists():
return YamlParser().parse(Path("peaks.yaml"))
if Path("ckit.yaml").exists():
return YamlParser().parse(Path("ckit.yaml"))
return {}
4 changes: 2 additions & 2 deletions peaks/config/yaml_parser.py → ckit/config/yaml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import yaml
from yaml.loader import SafeLoader

from peaks.command import Command
from peaks.command_group import CommandGroup
from ckit.command import Command
from ckit.command_group import CommandGroup


class YamlParser:
Expand Down
6 changes: 3 additions & 3 deletions peaks/core.py → ckit/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from blessed import Terminal

from peaks.config.config import Config
from peaks.screens.group_picker import GroupPicker
from peaks.screens.picker import Picker
from ckit.config.config import Config
from ckit.screens.group_picker import GroupPicker
from ckit.screens.picker import Picker


@dataclass
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Configuration

_peaks_ looks for configuration in the following two locations
_ckit_ looks for configuration in the following two locations

- From a `peaks.yaml` file in the current directory
- From any `.yaml` file in the the global configuration directory, which is defaulted to `~/peaks`, but which can be overridden with the environment variable `peaks_HOME`.
- 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`.

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

Expand Down
32 changes: 16 additions & 16 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
<p align="center">
<h1>peaks</h1>
<h1>ckit</h1>
</p>

---

[![Release](https://img.shields.io/github/v/release/fpgmaas/peaks)](https://img.shields.io/github/v/release/fpgmaas/peaks)
[![Build status](https://img.shields.io/github/actions/workflow/status/fpgmaas/peaks/main.yml?branch=main)](https://github.com/fpgmaas/peaks/actions/workflows/main.yml?query=branch%3Amain)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/peaks)](https://pypi.org/project/peaks/)
[![codecov](https://codecov.io/gh/fpgmaas/peaks/branch/main/graph/badge.svg)](https://codecov.io/gh/fpgmaas/peaks)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/peaks)](https://pypistats.org/packages/peaks)
[![License](https://img.shields.io/github/license/fpgmaas/peaks)](https://img.shields.io/github/license/fpgmaas/peaks)
[![Release](https://img.shields.io/github/v/release/fpgmaas/ckit)](https://img.shields.io/github/v/release/fpgmaas/ckit)
[![Build status](https://img.shields.io/github/actions/workflow/status/fpgmaas/ckit/main.yml?branch=main)](https://github.com/fpgmaas/ckit/actions/workflows/main.yml?query=branch%3Amain)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/ckit)](https://pypi.org/project/ckit/)
[![codecov](https://codecov.io/gh/fpgmaas/ckit/branch/main/graph/badge.svg)](https://codecov.io/gh/fpgmaas/ckit)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/ckit)](https://pypistats.org/packages/ckit)
[![License](https://img.shields.io/github/license/fpgmaas/ckit)](https://img.shields.io/github/license/fpgmaas/ckit)

_peaks_ is a command line utility to help you organise and quickly run frequently used commands.
_ckit_ is a command line utility to help you organise and quickly run frequently used commands.

<p align="center">
<img src="peaks.gif"/>
<img src="ckit.gif"/>
</p>

## Quickstart

### Installation

_peaks_ can be installed by running
_ckit_ can be installed by running

```shell
pip install peaks
pip install ckit
```

To get started, run

```shell
peaks init
ckit init
```

which will prompt to add a `peaks/peaks.yaml` file in the user's home directory for global commands, and/or a `peaks.yaml` file in the current directory for commands specific to the current project.
which will prompt to add a `ckit/ckit.yaml` file in the user's home directory for global commands, and/or a `ckit.yaml` file in the current directory for commands specific to the current project.

To use _peaks_ to run any of the pre-configured commands, simply run
To use _ckit_ to run any of the pre-configured commands, simply run

```
peaks
ckit
```

For details regarding the configuration files, see the [configuration](https://fpgmaas.github.io/peaks/configuration) section of the documentation.
For details regarding the configuration files, see the [configuration](https://fpgmaas.github.io/ckit/configuration) section of the documentation.

---

Expand Down
Loading

0 comments on commit cc98c7e

Please sign in to comment.