Skip to content

Commit

Permalink
Testing new regex to capture arguments with dashes in them
Browse files Browse the repository at this point in the history
  • Loading branch information
dluman committed Dec 20, 2023
1 parent 11d0d8a commit 1c5ee3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/arglite.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class Parser:

def __init__(self):
""" Entry point. """
#self.file = sys.argv[0]
self.file = self.caller()
self.h, self.help = None, None
arg_str = self.flatten(sys.argv[1:])
Expand Down Expand Up @@ -80,7 +79,8 @@ def flatten(self, args: list = []) -> str:

def pairs(self, args: str = "") -> list:
""" Get each pair of args and values, blanks if no value """
return re.findall(r"-{1,2}([^-][a-z]*(?:\s)?)([^-]*)", args)
return re.findall(r"((?<![a-z])-{1,2}[a-z0-9]+)(?:\s)([a-z0-9-]+)", args)
#return re.findall(r"-{1,2}([^-][a-z]*(?:\s)?)([^-]*)", args)

def typify(self, val: Any) -> Any:
""" Cast as a data structure or other type if possible, else...meh """
Expand Down

0 comments on commit 1c5ee3b

Please sign in to comment.