Skip to content

Commit 939a686

Browse files
committed
housekeeping
1 parent e680683 commit 939a686

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ class Package(setup_boilerplate.Package):
2222
'Programming Language :: Python :: 3.7',
2323
'Programming Language :: Python :: 3.8',
2424
'Programming Language :: Python :: 3 :: Only',
25-
'Topic :: Utilities']
25+
'Topic :: Software Development :: Version Control',
26+
'Topic :: Software Development :: Version Control :: Git',
27+
'Topic :: System :: Software Distribution',
28+
'Topic :: Utilities',
29+
'Typing :: Typed']
2630
keywords = [
2731
'automation', 'continous integration', 'git', 'releasing', 'semantic versioning', 'tagging',
2832
'versioning']

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
logging.getLogger().setLevel(logging.WARNING)
1414
logging.getLogger('version_query').setLevel(
1515
getattr(logging, os.environ.get('LOGGING_LEVEL', 'debug').upper()))
16+
logging.getLogger('test').setLevel(logging.DEBUG)

version_query/main.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
import logging
55
import os
66
import pathlib
7+
import sys
78

89
from ._version import VERSION
910
from .version import VersionComponent
1011
from .query import query_folder, predict_folder
1112

1213

13-
def main(args=None) -> None:
14-
"""Entry point of the command-line interface."""
14+
def main(args=None, namespace=None) -> None:
15+
"""Run the command-line interface.
16+
17+
Either query or predict version in a given folder according to the arguments.
18+
"""
1519
logging_level = getattr(logging, os.environ.get('LOGGING_LEVEL', 'warning').upper())
1620
logging.basicConfig(level=min(logging_level, logging.WARNING))
1721
logging.getLogger().setLevel(logging.WARNING)
@@ -28,15 +32,16 @@ def main(args=None) -> None:
2832
i.e. assume existence of git repository and infer current version from
2933
its tags, history and working tree status''')
3034
parser.add_argument('path', type=pathlib.Path)
31-
parser.add_argument('--version', action='version', version=VERSION)
32-
args = parser.parse_args(args)
33-
if args.predict and args.increment:
35+
parser.add_argument('--version', action='version',
36+
version=f'{parser.prog} {VERSION},\nPython {sys.version}')
37+
parsed_args = parser.parse_args(args=args, namespace=namespace)
38+
if parsed_args.predict and parsed_args.increment:
3439
raise ValueError(
3540
'choose one: either increment current version, or predict upcoming version')
36-
if args.predict:
37-
version = predict_folder(args.path)
41+
if parsed_args.predict:
42+
version = predict_folder(parsed_args.path)
3843
else:
39-
version = query_folder(args.path)
40-
if args.increment:
44+
version = query_folder(parsed_args.path)
45+
if parsed_args.increment:
4146
version.increment(VersionComponent.Patch)
4247
print(version)

0 commit comments

Comments
 (0)