diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e32da6b..6240767 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,9 @@ - + + + + - @@ -357,7 +359,13 @@ - + + + + + + + diff --git a/je_auto_control/__main__.py b/je_auto_control/__main__.py index 13b2b86..ad4beb1 100644 --- a/je_auto_control/__main__.py +++ b/je_auto_control/__main__.py @@ -2,13 +2,32 @@ import argparse from je_auto_control.utils.json.json_file import read_action_json +from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list from je_auto_control.utils.executor.action_executor import execute_action +from je_auto_control.utils.executor.action_executor import execute_files + + +def preprocess_execute_action(file_path: str): + execute_action(read_action_json(file_path)) + + +def preprocess_execute_files(file_path: str): + execute_files(get_dir_files_as_list(file_path)) + + +argparse_event_dict = { + "execute_file": preprocess_execute_action, + "execute_dir": preprocess_execute_files +} if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-e", "--execute_file", type=str, help="choose action file to execute") + parser.add_argument("-d", "--execute_dir", type=str, help="choose dir include action file to execute") args = parser.parse_args() - if args.execute_file is not None: - execute_action(read_action_json(args.execute_file)) - else: - print("No argument, Hello There :)") + args = vars(args) + print(args) + for key, value in args.items(): + if value is not None: + argparse_event_dict.get(key)(value) + diff --git a/setup.py b/setup.py index df9d9f5..55f07e2 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="je_auto_control", - version="0.0.87", + version="0.0.88", author="JE-Chen", author_email="zenmailman@gmail.com", description="auto testing", diff --git a/test/unit_test/argparse/argparse_test.py b/test/unit_test/argparse/argparse_test.py index 6368302..0e41f2d 100644 --- a/test/unit_test/argparse/argparse_test.py +++ b/test/unit_test/argparse/argparse_test.py @@ -3,6 +3,5 @@ print(os.getcwd()) os.system("cd " + os.getcwd()) -os.system("python je_auto_control --execute_file " + os.getcwd() + r"/test/unit_test/argparse/test.json") - - +os.system("python je_auto_control --execute_file " + os.getcwd() + r"/test/unit_test/argparse/test1.json") +os.system("python je_auto_control --execute_dir " + os.getcwd() + r"/test/unit_test/argparse") diff --git a/test/unit_test/argparse/test.json b/test/unit_test/argparse/test1.json similarity index 100% rename from test/unit_test/argparse/test.json rename to test/unit_test/argparse/test1.json diff --git a/test/unit_test/argparse/test2.json b/test/unit_test/argparse/test2.json new file mode 100644 index 0000000..a8d8b9f --- /dev/null +++ b/test/unit_test/argparse/test2.json @@ -0,0 +1 @@ +[["type_key", {"keycode": 0}], ["mouse_left", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["position"], ["press_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}]] \ No newline at end of file diff --git a/test/unit_test/json/json_test.py b/test/unit_test/json/json_test.py index b1fffde..540bd1b 100644 --- a/test/unit_test/json/json_test.py +++ b/test/unit_test/json/json_test.py @@ -11,6 +11,6 @@ ["release_mouse", {"mouse_keycode": "mouse_left", "x": 500, "y": 500}], ] -write_action_json(os.getcwd() + "/test.json", test_list) -read_json = read_action_json(os.getcwd() + "/test.json") +write_action_json(os.getcwd() + "/test1.json", test_list) +read_json = read_action_json(os.getcwd() + "/test1.json") print(read_json)