diff --git a/README.md b/README.md index e01ee003..cbce3191 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ the titan of the sea. ## Table of Contents +- [Tools](#tools) - [Installation](#installation) - [Requirements](#requirements) - [Install using pip](#install-using-pip) @@ -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 , use conventional commits for release notes +pontos-release prepare --project -patch -CC +# Release that patch version of project +pontos-release release --project +# Sign a release: +pontos-release sign --project --release-version 1.2.3 --signing-key 1234567890ABCDEFEDCBA0987654321 [--passphrase ] +``` +* `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 +``` +* `pontos-changelog` - Parse conventional commits in the current branch, creating CHANGELOG.md file +```bash +# Parse conventional commits and create +pontos-changelog -o +``` +* pontos-github` - Handling GitHub operations, like Pull Requests (beta) +```bash +# create a PR on GitHub +pontos-github 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 diff --git a/pontos/__init__.py b/pontos/__init__.py new file mode 100644 index 00000000..3a6a9e27 --- /dev/null +++ b/pontos/__init__.py @@ -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 . + +from .pontos import main + +__all__ = ["main"] diff --git a/pontos/pontos.py b/pontos/pontos.py new file mode 100644 index 00000000..17e38ec2 --- /dev/null +++ b/pontos/pontos.py @@ -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 . + +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() diff --git a/pontos/release/main.py b/pontos/release/main.py index eaa1485f..c6076787 100644 --- a/pontos/release/main.py +++ b/pontos/release/main.py @@ -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( @@ -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', ) @@ -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' ), ) @@ -158,7 +158,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' ), ) release_parser.add_argument( @@ -166,7 +166,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', ) diff --git a/pyproject.toml b/pyproject.toml index ca181517..e4d07646 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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' diff --git a/tests/test_pontos.py b/tests/test_pontos.py new file mode 100644 index 00000000..0df00895 --- /dev/null +++ b/tests/test_pontos.py @@ -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 . + +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.' + )