remove unused code
This commit is contained in:
parent
1b42cd7f75
commit
a383186150
1 changed files with 12 additions and 38 deletions
|
|
@ -1,38 +1,36 @@
|
||||||
import argparse
|
import argparse
|
||||||
import dataclasses
|
import dataclasses
|
||||||
from enum import Enum
|
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from ytdl_sub import __local_version__
|
from ytdl_sub import __local_version__
|
||||||
from ytdl_sub.utils.logger import LoggerLevels
|
from ytdl_sub.utils.logger import LoggerLevels
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
@dataclasses.dataclass
|
||||||
class MainArgument:
|
class CLIArgument:
|
||||||
short: str
|
short: str
|
||||||
long: str
|
long: str
|
||||||
is_positional: bool = False
|
is_positional: bool = False
|
||||||
|
|
||||||
|
|
||||||
class MainArguments:
|
class MainArguments:
|
||||||
CONFIG = MainArgument(
|
CONFIG = CLIArgument(
|
||||||
short="-c",
|
short="-c",
|
||||||
long="--config",
|
long="--config",
|
||||||
)
|
)
|
||||||
DRY_RUN = MainArgument(
|
DRY_RUN = CLIArgument(
|
||||||
short="-d",
|
short="-d",
|
||||||
long="--dry-run",
|
long="--dry-run",
|
||||||
is_positional=True,
|
is_positional=True,
|
||||||
)
|
)
|
||||||
LOG_LEVEL = MainArgument(
|
LOG_LEVEL = CLIArgument(
|
||||||
short="-l",
|
short="-l",
|
||||||
long="--log-level",
|
long="--log-level",
|
||||||
is_positional=True,
|
is_positional=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def all(cls) -> List[MainArgument]:
|
def all(cls) -> List[CLIArgument]:
|
||||||
"""
|
"""
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
|
@ -52,24 +50,6 @@ class MainArguments:
|
||||||
all_args.extend([arg.short, arg.long])
|
all_args.extend([arg.short, arg.long])
|
||||||
return all_args
|
return all_args
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_argument_if_exists(cls, input_args: List[str]) -> Optional[str]:
|
|
||||||
"""
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
input_args
|
|
||||||
List of arguments
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
True if a Main argument is in the input arguments. False otherwise.
|
|
||||||
"""
|
|
||||||
for input_arg in input_args:
|
|
||||||
for main_arg in cls.all_arguments():
|
|
||||||
if input_arg == main_arg:
|
|
||||||
return input_arg
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
# SHARED OPTIONS
|
# SHARED OPTIONS
|
||||||
|
|
@ -140,24 +120,18 @@ download_parser = subparsers.add_parser("dl")
|
||||||
# VIEW PARSER
|
# VIEW PARSER
|
||||||
|
|
||||||
|
|
||||||
class ViewArgs(Enum):
|
class ViewArguments:
|
||||||
SPLIT_CHAPTERS = "--split-chapters"
|
SPLIT_CHAPTERS = CLIArgument(
|
||||||
|
short="-sc",
|
||||||
@classmethod
|
long="--split-chapters",
|
||||||
def all(cls) -> List[str]:
|
)
|
||||||
"""
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
List of all args used in main CLI
|
|
||||||
"""
|
|
||||||
return list(map(lambda arg: arg.value, cls))
|
|
||||||
|
|
||||||
|
|
||||||
view_parser = subparsers.add_parser("view")
|
view_parser = subparsers.add_parser("view")
|
||||||
_add_shared_arguments(view_parser, suppress_defaults=True)
|
_add_shared_arguments(view_parser, suppress_defaults=True)
|
||||||
view_parser.add_argument(
|
view_parser.add_argument(
|
||||||
"-sc",
|
ViewArguments.SPLIT_CHAPTERS.short,
|
||||||
ViewArgs.SPLIT_CHAPTERS.value,
|
ViewArguments.SPLIT_CHAPTERS.long,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="View source variables after splitting by chapters",
|
help="View source variables after splitting by chapters",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue