Automatically update CLI help on readme, during development

This commit is contained in:
Isaiah Odhner 2023-09-05 17:38:46 -04:00
parent e200501518
commit c610019430
2 changed files with 11 additions and 7 deletions

View File

@ -12,5 +12,7 @@ __license__ = "MIT"
# to distinguish production from development versions.
from os.path import exists, dirname
from subprocess import check_output
if exists(dirname(__file__) + "/../../.git"):
DEVELOPMENT = exists(dirname(__file__) + "/../../.git")
"""Whether running from a Git repository."""
if DEVELOPMENT:
__version__ = "development " + check_output(["git", "describe", "--tags"], cwd=dirname(__file__)).strip().decode()

View File

@ -4,7 +4,7 @@ import argparse
import os
import re
from .__init__ import __version__
from .__init__ import __version__, DEVELOPMENT
parser = argparse.ArgumentParser(description='Paint in the terminal.', usage='%(prog)s [options] [filename]', prog="textual-paint")
parser.add_argument('--version', action='version', version=f'%(prog)s {__version__}')
@ -60,11 +60,13 @@ def update_cli_help_on_readme():
f.seek(0)
f.write(md)
f.truncate()
# Manually disabled for release.
# TODO: disable for release builds, while keeping it automatic during development.
# (I could make this another dev flag, but I like the idea of it being automatic.)
# (Maybe a pre-commit hook would be ideal, if it's worth the complexity.)
# update_cli_help_on_readme()
if DEVELOPMENT:
# A pre-commit hook might technically be best for this,
# but I doubt it's worth the complexity.
# I'm usually running with --restart-on-changes anyways,
# while working on the project.
update_cli_help_on_readme()
args = parser.parse_args()
"""Parsed command line arguments."""