Update formating
This commit is contained in:
parent
8fdb78b908
commit
94edd899d0
4 changed files with 20 additions and 14 deletions
|
@ -1,7 +1,13 @@
|
|||
from command_parser.option import Option
|
||||
|
||||
|
||||
class Flag(Option):
|
||||
def __init__(self, name: str, default: bool = False, single_char: str | None = None) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
default: bool = False,
|
||||
single_char: str | None = None,
|
||||
) -> None:
|
||||
super(Flag, self).__init__(name, single_char)
|
||||
self.value = default
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from command_parser import logger
|
||||
|
||||
|
||||
class Option:
|
||||
def __init__(self, name: str, single_char: str | None = None) -> None:
|
||||
logger.debug(
|
||||
_("creating new option with the name {name}")
|
||||
)
|
||||
def __init__(
|
||||
self, name: str, single_char: str | None = None
|
||||
) -> None:
|
||||
logger.debug(_("creating new option with the name {name}"))
|
||||
if single_char is None:
|
||||
logger.debug(
|
||||
_(
|
||||
|
@ -18,12 +19,10 @@ class Option:
|
|||
_(
|
||||
"char representation should be only one char "
|
||||
+ "long"
|
||||
)
|
||||
)
|
||||
)
|
||||
logger.debug(
|
||||
_(
|
||||
"single char {char} defined"
|
||||
).format(char = single_char)
|
||||
_("single char {char} defined").format(char=single_char)
|
||||
)
|
||||
self.name = name
|
||||
self.single_char = single_char
|
||||
|
|
|
@ -3,6 +3,7 @@ from command_parser import logger
|
|||
from command_parser.flag import Flag
|
||||
from command_parser.value import Value
|
||||
|
||||
|
||||
def parse(line: str, flags: list[Flag], values: list[Value]):
|
||||
"""
|
||||
parse a command line parser
|
||||
|
@ -46,7 +47,7 @@ def parse(line: str, flags: list[Flag], values: list[Value]):
|
|||
index += 1
|
||||
for value in values:
|
||||
if value.long() == element[: len(value.long())]:
|
||||
value.apply(element[len(value.long()):])
|
||||
value.apply(element[len(value.long()) :])
|
||||
index += 1
|
||||
except IndexError:
|
||||
logger.warning(_("empty value"))
|
||||
|
|
|
@ -15,14 +15,14 @@ class Value(Option):
|
|||
if allowlist is None:
|
||||
logger.debug(
|
||||
_("every values is accepted for {option}").format(
|
||||
option = self.name,
|
||||
option=self.name,
|
||||
)
|
||||
)
|
||||
else:
|
||||
logger.debug(
|
||||
_(
|
||||
"only some values is accepted for {option}".format(
|
||||
option = self.name
|
||||
option=self.name
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ class Value(Option):
|
|||
"{value} is not an accepted value for the "
|
||||
+ "option {option}"
|
||||
).format(
|
||||
value = value,
|
||||
option = self.name,
|
||||
value=value,
|
||||
option=self.name,
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue