[scripts/init] add '-g/--git' command-line option
This commit is contained in:
@@ -52,6 +52,8 @@ def init_extractor(args):
|
|||||||
if func(args, lines):
|
if func(args, lines):
|
||||||
with util.lazy(path) as fp:
|
with util.lazy(path) as fp:
|
||||||
fp.writelines(lines)
|
fp.writelines(lines)
|
||||||
|
else:
|
||||||
|
LOG.warning("'%s' already present", category)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with util.open(path, args.open_mode) as fp:
|
with util.open(path, args.open_mode) as fp:
|
||||||
@@ -61,6 +63,9 @@ def init_extractor(args):
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
LOG.error("%s: %s", exc.__class__.__name__, exc, exc_info=exc)
|
LOG.error("%s: %s", exc.__class__.__name__, exc, exc_info=exc)
|
||||||
|
|
||||||
|
if args.git:
|
||||||
|
util.git("add", path)
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Extractor ###################################################################
|
# Extractor ###################################################################
|
||||||
@@ -308,6 +313,9 @@ def parse_args(args=None):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-F", "--force",
|
"-F", "--force",
|
||||||
dest="open_mode", action="store_const", const="w", default="x")
|
dest="open_mode", action="store_const", const="w", default="x")
|
||||||
|
parser.add_argument(
|
||||||
|
"-g", "--git",
|
||||||
|
dest="git", action="store_true")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-M", "--no-module",
|
"-M", "--no-module",
|
||||||
dest="init_module", action="store_false")
|
dest="init_module", action="store_false")
|
||||||
|
|||||||
Reference in New Issue
Block a user