Beispiel #1
0
def run_command(cmd, cmd_string):
    """Run the command entered by the user.
    Args:
        cmd (str): This is the command, e.g. group
        cmd_string (str): The parameters of the command

    Returns:
        None

    """
    cmd = cmd.lower()
    if cmd in CMD_DICT_ARGS:
        func = CMD_DICT_ARGS[cmd]
        func(cmd_string)
    elif cmd in CMD_DICT:
        func = CMD_DICT[cmd]
        func()
    else:
        print_usage()
Beispiel #2
0
CMD_DICT_ARGS = {'group': group_bookmarks, 'add': add_bookmarks, 'delete':del_bookmarks}
CMD_DICT = {'open':open_bookmarks, 'list': list_bookmarks}

def run_command(cmd, cmd_string):
    """Run the command entered by the user.
    Args:
        cmd (str): This is the command, e.g. group
        cmd_string (str): The parameters of the command

    Returns:
        None

    """
    cmd = cmd.lower()
    if cmd in CMD_DICT_ARGS:
        func = CMD_DICT_ARGS[cmd]
        func(cmd_string)
    elif cmd in CMD_DICT:
        func = CMD_DICT[cmd]
        func()
    else:
        print_usage()

if __name__ == '__main__':
    if not sys.argv[1:]:
        print_usage()
        exit()
    else:
        (cmd, cmd_string) = get_command(sys.argv)
        run_command(cmd, cmd_string)