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

Add a debug CLI command #97

Closed
wants to merge 4 commits into from
Closed

Add a debug CLI command #97

wants to merge 4 commits into from

Conversation

ogizanagi
Copy link
Member

@ogizanagi ogizanagi commented May 28, 2021

Introduce a new debug:stenope:content that'll be useful in multiple ways, to debug, list, filter and inspect contents managed by Stenope:

List

bin/console debug:stenope:content "App\Model\Page"

Capture d’écran 2021-05-28 à 16 40 01

Show

bin/console debug:stenope:content "App\Model\Index" README

Capture d’écran 2021-05-28 à 16 37 51

(change verbosity to display more)

Order & Filter

bin/console debug:stenope:content "App\Model\Article" \
   --filter="not:outdated" \
   --filter="slug contains:rebranding" \
   --order="desc:date"

Capture d’écran 2021-05-28 à 16 37 03


There are some minor improvments / changes included in this PR as well:

  • handle fragment (anchors) when linking content between them (see how we reference another document with an anchor in the documentation changes in this PR)
  • added the ability to provide a filter function for a specific property (it allows the --filter=field contains:text feature exposed in the command)
  • added the TableOfContent class. Small BC break (change your typehints from Headline[] to TableOfContent), but it allows to dump a simpler representation of the TOC when inspecting a content in non-verbose mode. It may also be useful later in case we need to introduce more data/config inside the TOC.
  • ContentManager::getContents now returns the slugs as keys

TODO

  • Add some functional tests for the debug command
  • Add unit & functional tests for resolving links with anchors
  • Add unit tests for filtering with a callable for a specific property
  • Add tests to reflect the keys for ContentManager::getContents
  • Later: interactively ask the class if not provided
  • Later: allow partial classname if no conflict and ask between matches otherwise
  • Later: dedicated & more powerful parser classes for orders & filters

@ogizanagi ogizanagi added the enhancement New feature or request label May 28, 2021
@ogizanagi ogizanagi requested a review from Tom32i May 28, 2021 14:40
ogizanagi added a commit that referenced this pull request Jun 2, 2021
This PR was squashed before being merged into the 0.x-dev branch.

Discussion
----------

Add a debug CLI command

Introduce a new `debug:stenope:content` that'll be useful in multiple ways, to debug, list, filter and inspect contents managed by Stenope:

## List

```bash
bin/console debug:stenope:content "App\Model\Page"
```

![Capture d’écran 2021-05-28 à 16 40 01](https://user-images.githubusercontent.com/2211145/120000690-5fba9480-bfd3-11eb-957a-db473f718fd6.png)

## Show

```bash
bin/console debug:stenope:content "App\Model\Index" README
```

![Capture d’écran 2021-05-28 à 16 37 51](https://user-images.githubusercontent.com/2211145/120000413-110cfa80-bfd3-11eb-83dc-67e0d7298359.png)

(change verbosity to display more)

## Order & Filter

```bash
bin/console debug:stenope:content "App\Model\Article" \
   --filter="not:outdated" \
   --filter="slug contains:rebranding" \
   --order="desc:date"
```

![Capture d’écran 2021-05-28 à 16 37 03](https://user-images.githubusercontent.com/2211145/120000280-f33f9580-bfd2-11eb-9ef2-1c70fe6c91d3.png)

---

There are some minor improvments / changes included in this PR as well:
- handle fragment (anchors) when linking content between them ([see how we reference another document with an anchor](https://github.com/StenopePHP/Stenope/pull/97/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R58) in the documentation changes in this PR)
- added the ability to provide a filter function for a specific property (it allows the `--filter=field contains:text` feature exposed in the command)
- added the `TableOfContent` class. Small BC break (change your typehints from `Headline[]` to `TableOfContent`), but it allows to dump a simpler representation of the TOC when inspecting a content in non-verbose mode. It may also be useful later in case we need to introduce more data/config inside the TOC.
- `ContentManager::getContents` now returns the slugs as keys

### TODO

- [x] Add some functional tests for the debug command
- [x] Add unit & functional tests for resolving links with anchors
- [x] Add unit tests for filtering with a callable for a specific property
- [x] Add tests to reflect the keys for `ContentManager::getContents`
- Later: interactively ask the class if not provided
- Later: allow partial classname if no conflict and ask between matches otherwise
- Later: dedicated & more powerful parser classes for orders & filters

Commits
-------

0279673 Add a debug CLI command
@ogizanagi
Copy link
Member Author

Merged in 0a01b1b

@ogizanagi ogizanagi closed this Jun 2, 2021
@ogizanagi ogizanagi deleted the debug-command branch June 2, 2021 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants