mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
new app preview img in docs
This commit is contained in:
-1199
File diff suppressed because it is too large
Load Diff
+10
-7
@@ -3,11 +3,14 @@ from typing import Literal
|
|||||||
|
|
||||||
|
|
||||||
class BaseArgument(ABC):
|
class BaseArgument(ABC):
|
||||||
@abstractmethod
|
|
||||||
def get_string_entity(self):
|
|
||||||
"""
|
"""
|
||||||
Returns the string representation of the argument
|
Private. Base class for all arguments
|
||||||
:return:
|
"""
|
||||||
|
@abstractmethod
|
||||||
|
def get_string_entity(self) -> str:
|
||||||
|
"""
|
||||||
|
Public. Returns the string representation of the argument
|
||||||
|
:return: the string representation as a str
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -15,7 +18,7 @@ class BaseArgument(ABC):
|
|||||||
class PositionalArgument(BaseArgument):
|
class PositionalArgument(BaseArgument):
|
||||||
def __init__(self, name: str):
|
def __init__(self, name: str):
|
||||||
"""
|
"""
|
||||||
Required argument at startup
|
Public. Required argument at startup
|
||||||
:param name: name of the argument, must not start with minus (-)
|
:param name: name of the argument, must not start with minus (-)
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -27,7 +30,7 @@ class PositionalArgument(BaseArgument):
|
|||||||
class OptionalArgument(BaseArgument):
|
class OptionalArgument(BaseArgument):
|
||||||
def __init__(self, name: str, prefix: Literal['-', '--', '---'] = '--'):
|
def __init__(self, name: str, prefix: Literal['-', '--', '---'] = '--'):
|
||||||
"""
|
"""
|
||||||
Optional argument, must have the value
|
Public. Optional argument, must have the value
|
||||||
:param name: name of the argument
|
:param name: name of the argument
|
||||||
:param prefix: prefix of the argument
|
:param prefix: prefix of the argument
|
||||||
"""
|
"""
|
||||||
@@ -41,7 +44,7 @@ class OptionalArgument(BaseArgument):
|
|||||||
class BooleanArgument(BaseArgument):
|
class BooleanArgument(BaseArgument):
|
||||||
def __init__(self, name: str, prefix: Literal['-', '--', '---'] = '--'):
|
def __init__(self, name: str, prefix: Literal['-', '--', '---'] = '--'):
|
||||||
"""
|
"""
|
||||||
Boolean argument, does not require a value
|
Public. Boolean argument, does not require a value
|
||||||
:param name: name of the argument
|
:param name: name of the argument
|
||||||
:param prefix: prefix of the argument
|
:param prefix: prefix of the argument
|
||||||
"""
|
"""
|
||||||
@@ -12,7 +12,7 @@ class ArgParse:
|
|||||||
description: str = 'Argenta available arguments',
|
description: str = 'Argenta available arguments',
|
||||||
epilog: str = 'github.com/koloideal/Argenta | made by kolo') -> None:
|
epilog: str = 'github.com/koloideal/Argenta | made by kolo') -> None:
|
||||||
"""
|
"""
|
||||||
Cmd argument parser and configurator at startup
|
Public. Cmd argument parser and configurator at startup
|
||||||
:param name: the name of the ArgParse instance
|
:param name: the name of the ArgParse instance
|
||||||
:param description: the description of the ArgParse instance
|
:param description: the description of the ArgParse instance
|
||||||
:param epilog: the epilog of the ArgParse instance
|
:param epilog: the epilog of the ArgParse instance
|
||||||
@@ -25,18 +25,18 @@ class ArgParse:
|
|||||||
self.entity: ArgumentParser = ArgumentParser(prog=name, description=description, epilog=epilog)
|
self.entity: ArgumentParser = ArgumentParser(prog=name, description=description, epilog=epilog)
|
||||||
self.args: list[PositionalArgument | OptionalArgument | BooleanArgument] | None = processed_args
|
self.args: list[PositionalArgument | OptionalArgument | BooleanArgument] | None = processed_args
|
||||||
|
|
||||||
def set_args(self, *args: PositionalArgument | OptionalArgument | BooleanArgument):
|
def set_args(self, *args: PositionalArgument | OptionalArgument | BooleanArgument) -> None:
|
||||||
"""
|
"""
|
||||||
Sets the arguments to be processed
|
Public. Sets the arguments to be processed
|
||||||
:param args: processed arguments
|
:param args: processed arguments
|
||||||
:return:
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.args.extend(args)
|
self.args.extend(args)
|
||||||
|
|
||||||
def register_args(self):
|
def register_args(self) -> None:
|
||||||
"""
|
"""
|
||||||
Registers initialized command line arguments
|
Private. Registers initialized command line arguments
|
||||||
:return:
|
:return: None
|
||||||
"""
|
"""
|
||||||
if not self.args:
|
if not self.args:
|
||||||
return
|
return
|
||||||
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
Reference in New Issue
Block a user