forked from p34709852/monkey
Improved readability in arg_parser.py
This commit is contained in:
parent
411345d603
commit
a17c01c7ee
|
@ -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 IslandArgs:
|
||||
setup_only: bool
|
||||
server_config_path: str
|
||||
class IslandCmdArgs:
|
||||
setup_only: bool = DEFAULT_SHOULD_SETUP_ONLY
|
||||
server_config_path: str = DEFAULT_SERVER_CONFIG_PATH
|
||||
|
||||
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
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
|
@ -27,4 +35,4 @@ def parse_cli_args() -> IslandArgs:
|
|||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
return IslandArgs(args.setup_only, args.server_config)
|
||||
return IslandCmdArgs(args.setup_only, args.server_config)
|
||||
|
|
Loading…
Reference in New Issue