#!/usr/bin/env python
#
# PyWake - Python Wake-On-LAN client
#
# Copyright 2013 Michal Belica <devel@beli.sk>
#
# This file is part of PyWake.
# 
# PyWake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# PyWake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with PyWake.  If not, see <http://www.gnu.org/licenses/>.

import pywake
from pywake import __version__

if __name__ == '__main__':
    import argparse
    pyw = pywake.PyWake(None)
    parser = argparse.ArgumentParser(description='PyWake - Wake-On-LAN client')
    parser.add_argument('mac', metavar='MAC', help='MAC address for "magic packet"')
    parser.add_argument('-s', '--src', '--source', dest='src_ip',
            help='source IP address to bind to')
    parser.add_argument('-d', '--dst', '--destination', dest='dst_ip',
            help='destination IP address (default: %s)' % pywake.IPV6_DEST)
    parser.add_argument('-p', '--port', dest='port', type=int, default=9,
            help='target UDP port (default: %d)' % pyw.port)
    group = parser.add_mutually_exclusive_group()
    group.add_argument('-4', '--ipv4', dest='ipv', action='store_const', const=4)
    group.add_argument('-6', '--ipv6', dest='ipv', action='store_const', const=6, default=None)
    parser.add_argument('-V', '--version', action='version', version='PyWake ' + __version__)
    parser.parse_args(namespace=pyw)
    pyw.send_packet()

