Open SakiiR opened 6 years ago
In Fact a better Argument parsing would be better.
https://docs.python.org/3/library/argparse.html
Il would be great if thoses kind of part use argparse:
def jabber_cmd_jabber(data, buffer, args): """ Command '/jabber'. """ global jabber_servers, jabber_config_option if args == "" or args == "list": jabber_list_servers_chats("") else: argv = args.split(" ") argv1eol = "" pos = args.find(" ") if pos > 0: argv1eol = args[pos+1:] if argv[0] == "list": jabber_list_servers_chats(argv[1]) elif argv[0] == "add": if len(argv) >= 4: server = jabber_search_server_by_name(argv[1]) if server: weechat.prnt("", "jabber: server '%s' already exists" % argv[1]) else: kwargs = {'jid': argv[2], 'password': argv[3]} if len(argv) > 4: conn_server, _, conn_port = argv[4].partition(':') if conn_port and not conn_port.isdigit(): weechat.prnt("", "jabber: error, invalid port, digits only") return weechat.WEECHAT_RC_OK if conn_server: kwargs['server'] = conn_server if conn_port: kwargs['port'] = conn_port server = Server(argv[1], **kwargs) jabber_servers.append(server) weechat.prnt("", "jabber: server '%s' created" % argv[1]) else: weechat.prnt("", "jabber: unable to add server, missing arguments") weechat.prnt("", "jabber: usage: /jabber add name jid password [server[:port]]") elif argv[0] == "alias": alias_command = AliasCommand(buffer, argv=argv[1:]) alias_command.run() elif argv[0] == "connect": # [...]
In Fact a better Argument parsing would be better.
https://docs.python.org/3/library/argparse.html
Il would be great if thoses kind of part use argparse: