forked from p15670423/monkey
Improved readability in the arg_parser.py by extracting defaults to the argparser flag section
This commit is contained in:
parent
7d1c5dd908
commit
0a7cf1d5ee
|
@ -1,18 +1,15 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from monkey_island.cc.server_utils.consts import (
|
from monkey_island.cc.server_utils.consts import (
|
||||||
DEFAULT_SERVER_CONFIG_PATH,
|
DEFAULT_SERVER_CONFIG_PATH,
|
||||||
DEFAULT_SHOULD_SETUP_ONLY,
|
DEFAULT_SHOULD_SETUP_ONLY,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class IslandCmdArgs:
|
class IslandCmdArgs:
|
||||||
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() -> IslandCmdArgs:
|
def parse_cli_args() -> IslandCmdArgs:
|
||||||
|
@ -29,9 +26,13 @@ def parse_cli_args() -> IslandCmdArgs:
|
||||||
help="Pass this flag to cause the Island to setup and exit without actually starting. "
|
help="Pass this flag to cause the Island to setup and exit without actually starting. "
|
||||||
"This is useful for preparing Island to boot faster later-on, so for "
|
"This is useful for preparing Island to boot faster later-on, so for "
|
||||||
"compiling/packaging Islands.",
|
"compiling/packaging Islands.",
|
||||||
|
default=DEFAULT_SHOULD_SETUP_ONLY,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--server-config", action="store", help="The path to the server configuration file."
|
"--server-config",
|
||||||
|
action="store",
|
||||||
|
help="The path to the server configuration file.",
|
||||||
|
default=DEFAULT_SERVER_CONFIG_PATH,
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue