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

import argparse


parser = argparse.ArgumentParser(description="Baulicht command line interface to change mode, add text,"
                                             " remove text or pause the blinking.",
                                 epilog="That's how to do it!")

parser.add_argument("-l", "--list", action='store_true', help="List all active texts")
parser.add_argument("-a", "--add", type=str, metavar='<string>', help="Add Text to morse")
parser.add_argument("-r", "--remove", type=int, metavar='<int>', help="Remove Text")
parser.add_argument("-m", "--mode", choices=["text", "blink"], help="Set mode to text or blink")
parser.add_argument("-s", "--speed", type=int, metavar='<int>', help="length of a dit in ms")
parser.add_argument("-b", "--blink", nargs="?", metavar='<list<int>>', help="Set blink interval")
parser.add_argument("-p", "--pause", choices=["on", "off"], help="Stop morse/blink")

args = parser.parse_args()

@@ -40,17 +40,16 @@
 f-8 -*-%0A
-%0A
 import a
@@ -953,32 +953,1001 @@
 k%22)%0A
-%0Aargs = parser.parse_args()%0A
+parser.add_argument(%22--status%22, action=%22store_true%22, help=%22Stop morse/blink%22)%0A%0Aargs = parser.parse_args()%0A%0A%0Aimport dbus%0Abus = dbus.SessionBus()%0Aroot_object = bus.get_object(%22de.naptower.Baulicht%22, %22/%22)%0A%0Aif args.status:%0A    print(%22Current System Status:%22)%0A    paused = root_object.paused()%0A    mode = root_object.mode()%0A    #speed = root_object.%0A    print(%22Paused: %25s%22 %25 (paused))%0A    print(%22Mode: %25s%22 %25 (mode))%0A    %0Aif args.add:%0A    path = root_object.addText(args.add , 1, 1)%0A    print('Added %22%25s%22. Path is %22%25s%22' %25 (args.add, path))%0A    %0Aif args.pause == %22on%22:%0A    root_object.setPaused(False)%0A    print(%22Start morse%22)%0Aelif args.pause == %22off%22:%0A    root_object.setPaused(True)%0A    print(%22Stop morse%22)%0A    %0Aif args.speed:%0A    root_object.setSpeed(args.speed)%0A    print(%22Set speed to %25d%22 %25 (args.speed))%0A%0Aif args.mode == %22text%22:%0A    root_object.setMode(0)%0A    print(%22Set mode to %25s%22 %25 (args.mode))%0Aelif args.mode == %22blink%22:%0A    root_object.setMode(1)%0A    print(%22Set mode to %25s%22 %25 (args.mode))%0A    

connect cli with dbus