Skip to content

Commit 74efacd

Browse files
committed
Add: Add a get_commands function to return all VersionCommand classes
Better abstract the available VersionCommand classes by providing a function to get access to them.
1 parent 7658b22 commit 74efacd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pontos/version/commands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
from typing import Tuple, Type
18+
from typing import Iterable, Tuple, Type
1919

2020
from pontos.version.errors import ProjectError
2121

@@ -47,3 +47,7 @@ def gather_project() -> VersionCommand:
4747
return command
4848

4949
raise ProjectError("No project settings file found")
50+
51+
52+
def get_commands() -> Iterable[Type[VersionCommand]]:
53+
return _COMMANDS

tests/version/test_commands.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from pontos.testing import temp_directory, temp_python_module
2121
from pontos.version.cmake import CMakeVersionCommand
22-
from pontos.version.commands import gather_project
22+
from pontos.version.commands import gather_project, get_commands
2323
from pontos.version.errors import ProjectError
2424
from pontos.version.go import GoVersionCommand
2525
from pontos.version.javascript import JavaScriptVersionCommand
@@ -71,3 +71,8 @@ def test_cmake_project_version(self):
7171
version_file.write_text("project(VERSION 1.2.3)", encoding="utf8")
7272

7373
self.assertIsInstance(gather_project(), CMakeVersionCommand)
74+
75+
76+
class GetCommandsTestCase(unittest.TestCase):
77+
def test_available_commands(self):
78+
self.assertEqual(len(get_commands()), 4)

0 commit comments

Comments
 (0)