[scripts/init] add '-g/--git' command-line option

This commit is contained in:
Mike Fährmann
2025-08-17 23:41:29 +02:00
parent f23f506362
commit 7dbd3e40f7

View File

@@ -52,6 +52,8 @@ def init_extractor(args):
if func(args, lines):
with util.lazy(path) as fp:
fp.writelines(lines)
else:
LOG.warning("'%s' already present", category)
else:
try:
with util.open(path, args.open_mode) as fp:
@@ -61,6 +63,9 @@ def init_extractor(args):
except Exception as exc:
LOG.error("%s: %s", exc.__class__.__name__, exc, exc_info=exc)
if args.git:
util.git("add", path)
###############################################################################
# Extractor ###################################################################
@@ -308,6 +313,9 @@ def parse_args(args=None):
parser.add_argument(
"-F", "--force",
dest="open_mode", action="store_const", const="w", default="x")
parser.add_argument(
"-g", "--git",
dest="git", action="store_true")
parser.add_argument(
"-M", "--no-module",
dest="init_module", action="store_false")