code: def handle_args_and_set_context(args):
    
    parser = argparse.ArgumentParser()
    parser.add_argument("service", help="name of service password is being generated for")
    parser.add_argument("env", help=", ".join(EFConfig.ENV_LIST))
    group = parser.add_mutually_exclusive_group()
    group.add_argument("--decrypt", help="encrypted string to be decrypted", default="")
    group.add_argument("--plaintext", help="secret to be encrypted rather than a randomly generated one", default="")
    group.add_argument("--secret_file", help="json file containing secrets to be encrypted", default="")
    parser.add_argument("--match", help="used in conjunction with --secret_file to match against keys to be encrypted", default="")
    parser.add_argument("--length", help="length of generated password (default 32)", default=32)
    parsed_args = vars(parser.parse_args(args))
    context = EFPWContext()
    try:
      context.env = parsed_args["env"]
    except ValueError as e:
      ef_utils.fail("Error in env: {}".format(e.message))
    context.service = parsed_args["service"]
    context.decrypt = parsed_args["decrypt"]
    context.length = parsed_args["length"]
    context.plaintext = parsed_args["plaintext"]
    context.secret_file = parsed_args["secret_file"]
    context.match = parsed_args["match"]
    if context.match or context.secret_file:
      if not context.match or not context.secret_file:
        raise ValueError("Must have both --match and --secret_file flag")
  
    return context
docs: Args:
        args: the command line args, probably passed from main() as sys.argv[1:]
    Returns:
        a populated EFPWContext object
    Raises:
        RuntimeError: if repo or branch isn't as spec'd in ef_config.EF_REPO and ef_config.EF_REPO_BRANCH
        ValueError: if a parameter is invalid