mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
work on support args
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
__all__ = ["BooleanArgument", "PositionalArgument", "OptionalArgument"]
|
||||
|
||||
|
||||
from argenta.orchestrator.arguments.models import (BooleanArgument,
|
||||
PositionalArgument,
|
||||
OptionalArgument)
|
||||
@@ -0,0 +1,50 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Literal
|
||||
|
||||
|
||||
class BaseArgument(ABC):
|
||||
@abstractmethod
|
||||
def get_string_entity(self):
|
||||
"""
|
||||
Returns the string representation of the argument
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class PositionalArgument(BaseArgument):
|
||||
def __init__(self, name: str):
|
||||
"""
|
||||
Required argument at startup
|
||||
:param name: name of the argument, must not start with minus (-)
|
||||
"""
|
||||
self.name = name
|
||||
|
||||
def get_string_entity(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class OptionalArgument(BaseArgument):
|
||||
def __init__(self, name: str, prefix: Literal['-', '--', '---']):
|
||||
"""
|
||||
Optional argument, must have the value
|
||||
:param name: name of the argument
|
||||
:param prefix: prefix of the argument
|
||||
"""
|
||||
self.name = name
|
||||
self.prefix = prefix
|
||||
|
||||
def get_string_entity(self):
|
||||
return self.prefix + self.name
|
||||
|
||||
|
||||
class BooleanArgument(BaseArgument):
|
||||
def __init__(self, name: str):
|
||||
"""
|
||||
Boolean argument, does not require a value
|
||||
:param name: name of the argument
|
||||
"""
|
||||
self.name = name
|
||||
|
||||
def get_string_entity(self):
|
||||
return self.name
|
||||
Reference in New Issue
Block a user