refactor: only accept known args

This commit is contained in:
Daylin Morgan 2022-09-14 00:37:16 -05:00
parent 5eb3e21b51
commit ea398af49a
3 changed files with 7 additions and 8 deletions

View file

@ -6,7 +6,6 @@ msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','b
msg = $(call tprint,$(call msgfmt ,$(1))) msg = $(call tprint,$(call msgfmt ,$(1)))
### task.mk development | args: --divider --align center ### task.mk development | args: --divider --align center
## bootstrap | generate local dev environment ## bootstrap | generate local dev environment
.PHONY: bootstrap .PHONY: bootstrap
bootstrap: bootstrap:

View file

@ -21,10 +21,10 @@ pattern = re.compile(
def rawargs(argstring): def rawargs(argstring):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-a", "--align") parser.add_argument("--align")
parser.add_argument("-d", "--divider", action="store_true") parser.add_argument("-d", "--divider", action="store_true")
parser.add_argument("-ws", "--whitespace", action="store_true") parser.add_argument("-ws", "--whitespace", action="store_true")
return parser.parse_known_args(argstring.split()) return parser.parse_args(argstring.split())
def gen_makefile(): def gen_makefile():
@ -56,7 +56,7 @@ def print_goal(goal, msg, max_goal_len):
def print_rawmsg(msg, argstr, maxlens): def print_rawmsg(msg, argstr, maxlens):
args, unknown = rawargs(argstr) args = rawargs(argstr)
if msg: if msg:
if args.align == "sep": if args.align == "sep":
print( print(

View file

@ -1,7 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ # # }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan # Copyright (c) 2022 Daylin Morgan
# MIT License # MIT License
# version: v22.9.12-6-gf9cb3f6-dev # version: v22.9.12-7-g5eb3e21-dev
# #
# task.mk should be included at the bottom of your Makefile. # task.mk should be included at the bottom of your Makefile.
# See below for the standard configuration options that should be set prior to including this file. # See below for the standard configuration options that should be set prior to including this file.
@ -116,10 +116,10 @@ pattern = re.compile(
def rawargs(argstring): def rawargs(argstring):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-a", "--align") parser.add_argument("--align")
parser.add_argument("-d", "--divider", action="store_true") parser.add_argument("-d", "--divider", action="store_true")
parser.add_argument("-ws", "--whitespace", action="store_true") parser.add_argument("-ws", "--whitespace", action="store_true")
return parser.parse_known_args(argstring.split()) return parser.parse_args(argstring.split())
def gen_makefile(): def gen_makefile():
@ -151,7 +151,7 @@ def print_goal(goal, msg, max_goal_len):
def print_rawmsg(msg, argstr, maxlens): def print_rawmsg(msg, argstr, maxlens):
args, unknown = rawargs(argstr) args = rawargs(argstr)
if msg: if msg:
if args.align == "sep": if args.align == "sep":
print( print(