#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''
This script connects to a server to execute some command lines of a job.
'''

import argparse

from hateno.job import JobClient

def addArguments(parser):
	parser.add_argument('job_dir', type = str, help = 'path to the job directory to store the messaging files')

def main(args):
	with JobClient(args.job_dir) as client:
		client.events.addListener('received', lambda cmd: print(f'New command received:\n{cmd}'))
		client.events.addListener('sent', lambda log: print(f'Log sent:\n{log}'))

		client.run()

if __name__ == '__main__':
	parser = argparse.ArgumentParser(description = 'Run the client part of a job')
	addArguments(parser)
	main(parser.parse_args())
