Commit 6dd51d98 authored by Kyle Anderson's avatar Kyle Anderson

Add CLI interface for interface module

The electron app will be interacting with the interface module over the standard input, so arguments have been added for this.
parent 1d3f1d50
......@@ -15,7 +15,8 @@ def authenticate_user(base_dir: str = os.getcwd()) -> str:
:param base_dir: The base directory, from which all default paths are relative. Defaults to current working directory.
:return: The user_id of the recognized user, or empty string if none was recognized.
"""
recognized = authenticate.recognize_user_from_database(database_loc=os.path.join(base_dir, common.DATA_DIR))
recognized = authenticate.recognize_user_from_database(
database_loc=os.path.join(base_dir, common.DATABASE_LOC))
return recognized if recognized is not None else ""
......@@ -25,5 +26,24 @@ def register_user(base_dir: str = os.getcwd()) -> None:
:param base_dir: The base directory, from which all default paths are relative. Defaults to current working directory.
:return: None
"""
register.register_users_and_save(directory_location=os.path.join(base_dir, common.DATASET_DIR),
register.register_users_and_save(directory_location=os.path.join(base_dir, common.DATABASE_LOC),
delete_images_on_complete=True, overwrite_data=False)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="API Interface Options")
parser.add_argument("--base-dir", type=str, required=False, default=None,
help="The directory from which the save locations should be relative.")
parser.add_argument("--authenticate", required=False, default=False, action="store_true",
help="Present this argument to authenticate a user.")
parser.add_argument("--register", required=False, default=False, action="store_true",
help="Present this argument to register a user.")
args = parser.parse_args()
kwargs = dict(base_dir=args.base_dir)
if args.register:
register_user(**{arg_name: arg for (arg_name, arg) in kwargs.items() if args is not None})
elif args.authenticate:
print(authenticate_user(**{arg_name: arg for (arg_name, arg) in kwargs.items() if arg is not None}))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment