Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release 1.0.5 #8

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,34 @@
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

Generate .gitignore file without leaving the terminal.

![Ignori screenshot](./assets/ignori_screenshoot.png "Ignori Screenshot")
Ignori was built with [Textual](https://github.com/textualize/textual)

## Installation

To install `ignori`, it is recommended to use pip:

```shell
pip install ignori
```

You can install it from source. Clone this repository and use pip to install:

```shell
git clone https://github.com/EGAMAGZ/ignori.git
cd ignori
pip install .
```

## Usage

To start the app, run:

```shell
ignori
```

## Why?

Normally, when I start a project from scratch or the project initialiser does not generate a gitignore file, I have to search for it. With this, the workflow will not be interrupted by having to google it.
Expand Down
27 changes: 0 additions & 27 deletions ignori/styles/global.tcss
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# $primary: #F35530;
# $secondary: #F3AE9B;
# $background: #000000;
# $panel: #000000;
# $accent: #F35530;

$error: #EE678E;
$warning: #F6D661;
$success: #66EAC6;
Expand All @@ -22,27 +16,6 @@ $success: #66EAC6;
}
}

Header {
height: 1;
margin-bottom: 1;
padding: 0 2;
margin: 1 0;

& #app-title {
width: auto;
content-align: left middle;
color: $text;
background: $primary;
padding: 0 1;
}

& #app-version {
content-align: right middle;
color: $text 40%;
text-style: italic;
width:1fr;
}
}

.muted-text {
color: $text 20%;
Expand Down
24 changes: 23 additions & 1 deletion ignori/styles/widgets.tcss
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
BorderlessInput {
Header {
height: 1;
margin-bottom: 1;
padding: 0 2;
margin: 1 0;

& #app-title {
width: auto;
content-align: left middle;
color: $text;
background: $primary;
padding: 0 1;
}

& #app-version {
content-align: right middle;
color: $text 40%;
text-style: italic;
width:1fr;
}
}

Input {
border: none;
width: 1fr;
height: 1;
Expand Down
1 change: 0 additions & 1 deletion ignori/util/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def __get_files(template_subpath: Path, categories: list[str]) -> list[IgnoreFil


def get_gitignore_templates(templates_path: Path = TEMPLATES_PATH) -> list[IgnoreFile]:
print(templates_path)
template_files: list[IgnoreFile] = []
current_categories: list[str] = []

Expand Down
5 changes: 2 additions & 3 deletions ignori/widgets/generation_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from ignori.util.file import copy_file_content
from ignori.util.settings import DEFAULT_OUTPUT_FILE
from ignori.util.validators import PathValidator
from ignori.widgets.input import BorderlessInput
from ignori.widgets.language_badge import LanguageBadge


Expand Down Expand Up @@ -78,7 +77,7 @@ def generate_file(self: Self, event: Input.Submitted | Button.Pressed) -> None:

def validate_generation(self: Self, source_file: Path, output_path: Path) -> None:
def handle_confirm(
response: bool,
response: bool | None,
source_file: Path,
output_file: Path,
) -> None:
Expand Down Expand Up @@ -123,7 +122,7 @@ def compose(self: Self) -> ComposeResult:
)
with Horizontal(id="path-form-container"):
yield Label("Output:", classes="label")
yield BorderlessInput(
yield Input(
id="path-input",
placeholder=f"{Path.cwd()}",
type="text",
Expand Down
4 changes: 0 additions & 4 deletions ignori/widgets/input.py

This file was deleted.

3 changes: 1 addition & 2 deletions ignori/widgets/search_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ignori.ignore_file import IgnoreFile, get_option_by_id
from ignori.util.file import get_gitignore_templates
from ignori.widgets.file_preview import FilePreview
from ignori.widgets.input import BorderlessInput
from ignori.widgets.language_list import LanguageList


Expand Down Expand Up @@ -99,7 +98,7 @@ def watch_filtered_ignore_files(self: Self, ignore_files: list[IgnoreFile]) -> N

def compose(self: Self) -> ComposeResult:
with Horizontal(id="search-container"):
yield BorderlessInput(
yield Input(
placeholder="Language...",
type="text",
id="search-input",
Expand Down
5 changes: 0 additions & 5 deletions main.py

This file was deleted.

642 changes: 390 additions & 252 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions tests/functional_tests/test_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest
from textual.notifications import Notification, Notifications
from textual.widgets import Input

from ignori.app import IgnoriApp
from ignori.ignore_file import IgnoreFile
from ignori.widgets.input import BorderlessInput
from ignori.widgets.language_badge import LanguageBadge
from ignori.widgets.language_list import LanguageList

Expand All @@ -17,7 +17,7 @@ async def test_language_selection(language: str, data_dir: Path) -> None:
async with app.run_test() as pilot:
ignore_file = IgnoreFile(data_dir / "unit_tests" / f"{language}.gitignore")

search_input = pilot.app.query_one("#search-input", expect_type=BorderlessInput)
search_input = pilot.app.query_one("#search-input", expect_type=Input)
search_input.focus()
await pilot.press(*language)
await pilot.click("#search-button")
Expand Down Expand Up @@ -62,7 +62,7 @@ async def test_language_selection_and_unselection(

search_input = pilot.app.query_one(
"#search-input",
expect_type=BorderlessInput,
expect_type=Input,
)
search_input.clear()
search_input.focus()
Expand Down Expand Up @@ -97,13 +97,13 @@ async def test_language_selection_and_unselection(
async def test_generation_without_language_selection(path: str) -> None:
app = IgnoriApp()
async with app.run_test() as pilot:
path_input = pilot.app.query_one("#path-input", expect_type=BorderlessInput)
path_input = pilot.app.query_one("#path-input", expect_type=Input)
path_input.focus()

await pilot.press(*path)
await pilot.click("#path-button")

path_input = pilot.app.query_one("#path-input", expect_type=BorderlessInput)
path_input = pilot.app.query_one("#path-input", expect_type=Input)

notifications: Notifications = pilot.app._notifications # noqa

Expand Down Expand Up @@ -155,7 +155,7 @@ async def test_ignore_generation(

search_input = pilot.app.query_one(
"#search-input",
expect_type=BorderlessInput,
expect_type=Input,
)
search_input.focus()
await pilot.press(*language)
Expand All @@ -174,13 +174,13 @@ async def test_ignore_generation(
if option.id == ignore_file.id:
await pilot.press("enter")

path_input = pilot.app.query_one("#path-input", expect_type=BorderlessInput)
path_input = pilot.app.query_one("#path-input", expect_type=Input)
path_input.focus()

await pilot.press(*generated_file_dir)
await pilot.click("#path-button")

path_input = pilot.app.query_one("#path-input", expect_type=BorderlessInput)
path_input = pilot.app.query_one("#path-input", expect_type=Input)

assert path_input.is_valid
assert generated_file.read_text() == source_file.read_text()
Expand Down
8 changes: 4 additions & 4 deletions tests/functional_tests/test_search.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import pytest
from textual.widgets import Input

from ignori.app import IgnoriApp
from ignori.util.file import get_gitignore_templates
from ignori.widgets.input import BorderlessInput
from ignori.widgets.language_list import LanguageList


@pytest.mark.asyncio
async def test_empty_search() -> None:
app = IgnoriApp()
async with app.run_test() as pilot:
search_input = pilot.app.query_one("#search-input", expect_type=BorderlessInput)
search_input = pilot.app.query_one("#search-input", expect_type=Input)
search_input.focus()
await pilot.click("#search-button")

Expand All @@ -26,7 +26,7 @@ async def test_empty_search() -> None:
async def test_languages_search(language: str, option_count: int) -> None:
app = IgnoriApp()
async with app.run_test() as pilot:
search_input = pilot.app.query_one("#search-input", expect_type=BorderlessInput)
search_input = pilot.app.query_one("#search-input", expect_type=Input)
search_input.focus()
await pilot.press(*language)
await pilot.click("#search-button")
Expand All @@ -46,7 +46,7 @@ async def test_search_with_different_capitalization(
) -> None:
app = IgnoriApp()
async with app.run_test() as pilot:
search_input = pilot.app.query_one("#search-input", expect_type=BorderlessInput)
search_input = pilot.app.query_one("#search-input", expect_type=Input)
search_input.focus()
await pilot.press(*language)
await pilot.click("#search-button")
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ allowlist_externals=
poetry

commands=
poetry run pytest --basetemp={envtmpytestdir} -v
poetry run pytest --basetemp={envtmpdir} -v
Loading