Add bat version command to print BAT version

`bat --help` also prints the version, but it's nice to have an explicit
command for this that only prints the version and nothing else.
This commit is contained in:
Sybren A. Stüvel 2021-11-19 13:57:15 +01:00
parent 744609b2f0
commit 7dead42c43
3 changed files with 38 additions and 1 deletions

View File

@ -3,6 +3,10 @@
This file logs the changes that are actually interesting to users (new features, This file logs the changes that are actually interesting to users (new features,
changed functionality, fixed bugs). changed functionality, fixed bugs).
# Version 1.9 (in development)
- Add `bat version` command to print just the version number and exit.
# Version 1.8 (2021-11-09) # Version 1.8 (2021-11-09)
- Compatibility with read-only source files. When packing, file permissions are no longer copied. This means that BAT can modify paths in packed files, even when the source files were read-only. - Compatibility with read-only source files. When packing, file permissions are no longer copied. This means that BAT can modify paths in packed files, even when the source files were read-only.

View File

@ -24,7 +24,7 @@ import datetime
import logging import logging
import time import time
from . import blocks, common, pack, list_deps from . import blocks, common, pack, list_deps, version
def cli_main(): def cli_main():
@ -80,6 +80,7 @@ def cli_main():
blocks.add_parser(subparsers) blocks.add_parser(subparsers)
pack.add_parser(subparsers) pack.add_parser(subparsers)
list_deps.add_parser(subparsers) list_deps.add_parser(subparsers)
version.add_parser(subparsers)
args = parser.parse_args() args = parser.parse_args()
config_logging(args) config_logging(args)

View File

@ -0,0 +1,32 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# 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 2
# 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, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
#
# (c) 2021, Blender Foundation - Sybren A. Stüvel
"""Print version of BAT and exit."""
from blender_asset_tracer import __version__
def add_parser(subparsers):
"""Add argparser for this subcommand."""
parser = subparsers.add_parser("version", help=__doc__)
parser.set_defaults(func=cli_version)
def cli_version(_):
print(__version__)