Improved readability in arg_parser.py

This commit is contained in:
VakarisZ 2021-05-21 11:20:54 +03:00
parent 411345d603
commit a17c01c7ee
1 changed files with 15 additions and 7 deletions

View File

@ -1,13 +1,21 @@
from dataclasses import dataclass from monkey_island.cc.server_utils.consts import (
DEFAULT_SERVER_CONFIG_PATH,
DEFAULT_SHOULD_SETUP_ONLY,
)
@dataclass class IslandCmdArgs:
class IslandArgs: setup_only: bool = DEFAULT_SHOULD_SETUP_ONLY
setup_only: bool server_config_path: str = DEFAULT_SERVER_CONFIG_PATH
server_config_path: str
def __init__(self, setup_only: None, server_config_path: None):
if setup_only:
self.setup_only = setup_only
if server_config_path:
self.server_config_path = server_config_path
def parse_cli_args() -> IslandArgs: def parse_cli_args() -> IslandCmdArgs:
import argparse import argparse
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
@ -27,4 +35,4 @@ def parse_cli_args() -> IslandArgs:
) )
args = parser.parse_args() args = parser.parse_args()
return IslandArgs(args.setup_only, args.server_config) return IslandCmdArgs(args.setup_only, args.server_config)