Skip to content

Commit

Permalink
Add: pontos command that lists pontos features [#267]
Browse files Browse the repository at this point in the history
Add: `pontos` command that lists pontos features
  • Loading branch information
y0urself authored Jan 28, 2022
2 parents bd11228 + ff90ccb commit 058d76b
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 5 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ the titan of the sea.

## Table of Contents <!-- omit in toc -->

- [Tools](#tools)
- [Installation](#installation)
- [Requirements](#requirements)
- [Install using pip](#install-using-pip)
Expand All @@ -24,6 +25,59 @@ the titan of the sea.
- [Contributing](#contributing)
- [License](#license)

## Tools and Utilities

`pontos` comes with a continiously increasing set of features.
The following commands are currently available:

* `pontos-release` - Release handling utility for C and Python Projects
>We also provide easy-to-use [GitHub Actions](https://github.com/greenbone/actions/#usage), that we recommended to use instead of manually releasing with pontos-release.
```bash
# Prepare the next patch release (x.x.2) of project <foo>, use conventional commits for release notes
pontos-release prepare --project <foo> -patch -CC
# Release that patch version of project <foo>
pontos-release release --project <foo>
# Sign a release:
pontos-release sign --project <foo> --release-version 1.2.3 --signing-key 1234567890ABCDEFEDCBA0987654321 [--passphrase <for_that_key>]
```
* `pontos-version` - Version handling utility for C, Go and Python Projects
```bash
# Update version of this project to 22.1.1
pontos-version update 22.1.1
# Show current projects version
pontos-version show
```
* `pontos-update-header` - Handling Copyright header for various file types and licences
>We also provide an easy-to-use [GitHub Action](https://github.com/greenbone/actions/#usage), that updates copyright year in header of files and creates a Pull Request.
```bash
# Update year in Copyright header in files, also add missing headers
pontos-update-header -d <dir1> <dir2>
```
* `pontos-changelog` - Parse conventional commits in the current branch, creating CHANGELOG.md file
```bash
# Parse conventional commits and create <changelog_file>
pontos-changelog -o <changelog-file>
```
* pontos-github` - Handling GitHub operations, like Pull Requests (beta)
```bash
# create a PR on GitHub
pontos-github pr <orga/repo> <head> <target> <pr_title> [--body <pr_body>]
```

* pontos` also comes with a Terminal interface printing prettier outputs
```python
import pontos.terminal.terminal

term = terminal.Terminal()
with term.indent():
term.ok("Hello indented World")
```
* `pontos` also comes with git and GitHub APIs
```python
import pontos.git
import pontos.github
```

## Installation

### Requirements
Expand Down
21 changes: 21 additions & 0 deletions pontos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021-2022 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .pontos import main

__all__ = ["main"]
87 changes: 87 additions & 0 deletions pontos/pontos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021-2022 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from pontos.terminal.terminal import Terminal


def main() -> None:
term = Terminal()

term.print()
term.bold_info('pontos - Greenbone Python Utilities and Tools')
term.print()
term.print('The following commands are currently available:')
with term.indent():
term.bold_info(
'pontos-release - Release handling '
'utility for C and Python Projects'
)
term.print('usage:')
with term.indent():
term.print('pontos-release {prepare,release,sign} -h')
term.bold_info(
'pontos-version - Version handling utility '
'for C, Go and Python Projects'
)
term.print('usage:')
with term.indent():
term.print('pontos-version {verify,show,update} -h')
term.bold_info(
'pontos-update-header - Handling Copyright header '
'for various file types and licences'
)
term.print('usage:')
with term.indent():
term.print('pontos-update-header -h')
term.bold_info(
'pontos-changelog - Parse conventional commits in the '
'current branch, creating CHANGELOG.md file'
)
term.print('usage:')
with term.indent():
term.print('pontos-changelog -h')
term.bold_info(
'pontos-github - Handling GitHub operations, like '
'Pull Requests (beta)'
)
term.print('usage:')
with term.indent():
term.print('pontos-github {pr} -h')
term.print()
term.info(
'pontos also comes with a Terminal interface '
'printing prettier outputs'
)
with term.indent():
term.print('Accessable with import "pontos.terminal"')
term.info('pontos also comes with git and GitHub APIs')
with term.indent():
term.print(
'Accessable with "import pontos.git" '
'and "import pontos.github"'
)

term.print()
term.warning(
'Use the listed commands "help" for more information '
'and arguments description.'
)


if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions pontos/release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def initialize_default_parser() -> ArgumentParser:
'--changelog',
help=(
'The CHANGELOG file path, defaults '
'to CHANGELOG.md in the repository root directory',
'to CHANGELOG.md in the repository root directory'
),
)
prepare_parser.add_argument(
Expand All @@ -102,7 +102,7 @@ def initialize_default_parser() -> ArgumentParser:
'-CC',
help=(
'Wether to use conventional commits and create '
'the changelog directly from the git log',
'the changelog directly from the git log'
),
action='store_true',
)
Expand All @@ -128,7 +128,7 @@ def initialize_default_parser() -> ArgumentParser:
'--next-version',
help=(
'Sets the next PEP 440 compliant version in project definition '
'after the release. default: set to next dev version',
'after the release. default: set to next dev version'
),
)

Expand Down Expand Up @@ -158,15 +158,15 @@ def initialize_default_parser() -> ArgumentParser:
'--changelog',
help=(
'The CHANGELOG file path, defaults '
'to CHANGELOG.md in the repository root directory',
'to CHANGELOG.md in the repository root directory'
),
)
release_parser.add_argument(
'--conventional-commits',
'-CC',
help=(
'Wether to use conventional commits and create '
'the changelog directly from the git log',
'the changelog directly from the git log'
),
action='store_true',
)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mode = "poetry"
version-module-file = "pontos/version/__version__.py"

[tool.poetry.scripts]
pontos = 'pontos:main'
pontos-version = 'pontos.version:main'
pontos-release = 'pontos.release:main'
pontos-update-header = 'pontos.updateheader:main'
Expand Down
37 changes: 37 additions & 0 deletions tests/test_pontos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2022 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from unittest.mock import patch

from pontos import main


class TestPontos(unittest.TestCase):
@patch("pontos.pontos.Terminal")
def test_pontos(self, terminal_mock):
main()

terminal_mock.return_value.print.assert_called()
terminal_mock.return_value.indent.assert_called()
terminal_mock.return_value.bold_info.assert_called()
terminal_mock.return_value.info.assert_called()
terminal_mock.return_value.warning.assert_called_once_with(
'Use the listed commands "help" for more information '
'and arguments description.'
)

0 comments on commit 058d76b

Please sign in to comment.