#!/usr/bin/env python
"""
    jldtouch

    @author: Jean-Lou Dupont
"""
__version__="0.1"
import os, sys, argparse
op=os.path

try:
    import jlddk #@UnusedImport
except:
    ### must be in dev mode then    
    this_dir=op.dirname(__file__)
    lib_path=op.abspath(op.join(this_dir, ".."))
    sys.path.insert(0, lib_path)
    import jlddk #@UnusedImport

########################################################################

DESC="""Receive from stdin a filename path, touch filename in specified directory - v%s""" % __version__

def main():
    try:
        import jlddk.do_setup  #@UnusedImport
        import logging
        import jlddk.do_checks #@UnusedImport
        
        parser=argparse.ArgumentParser(description=DESC, fromfile_prefix_chars='@', formatter_class=argparse.RawTextHelpFormatter)
        
        parser.add_argument('-dp',   dest='path_dest',     type=str,  help="Destination path", required=True)
        parser.add_argument('-aext', dest='append_ext',    type=str,  help="Append extension", default=None)
        parser.add_argument('-dpt',  dest='disable_pass_through',    action="store_true",  help="Disable pass-through stdin-->stdout", default=False)
        
        from jlddk.script_touch import run
        from jlddk.tools_sys import process_command_line
        args=process_command_line(parser)
        run(**args)

    except KeyboardInterrupt:
        logging.info("..Exiting")
        sys.exit(0)##no probs
        
    except Exception,e:
        logging.error(str(e))
        sys.exit(1)
        
sys.exit(main())
