From a17c01c7ee6fca980aa240e5fe286ca22aa5f1c5 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Fri, 21 May 2021 11:20:54 +0300 Subject: [PATCH] Improved readability in arg_parser.py --- monkey/monkey_island/cc/arg_parser.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/monkey/monkey_island/cc/arg_parser.py b/monkey/monkey_island/cc/arg_parser.py index 338db153d..457ffbac2 100644 --- a/monkey/monkey_island/cc/arg_parser.py +++ b/monkey/monkey_island/cc/arg_parser.py @@ -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)