Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root := help:
- root.print_help()
- exit(-2)
- help := '-h'
- help += '--help'
- root += version:
- root.print_version()
- exit(-1)
- version := '-v'
- version += '--version'
- root += command
- root += 'help' command:
- command.print_help()
- root += command '--help' => 'help' command
- root += 'version' command:
- command.print_version()
- root += command '--version' => 'version' command:
- command := 'node' node
- command.node := 'list':
- node_list()
- command.node += 'attach' name connect_string optional(force):
- if node.is_available(node_name):
- message = 'node "%s" is already defined' % name
- if force:
- root.warning('%s, would be replaced' % message)
- else:
- root.error(message)
- node_attach(name, connect_string)
- command.node.connect_string := user host port:
- return dict(user=user, host=host, port=port)
- command.node.connect_string.user := '([a-z]+[a-z0-9._]*)@':
- return args[1]
- host := '[a-z]+[a-z0-9._]*'
- host += '(digit{1,3})\.(digit{1,3})\.(digit{1,3})\.(digit{1,3})':
- result = []
- for byte in args[1:]:
- if int(byte) > 255:
- root.error('invalid ip address')
- else:
- result.append(int(byte))
- return args[0]
- command.node.connect_string.port := '(digit)+:' :
- if int(args) > 2**16:
- root.error('too big port number')
- else:
- return int(args)
- command.node.detach := 'detach' name optional(force):
- if not node.is_available(node_name):
- message = 'node "%s" did not found' % name
- if force:
- root.warning(message)
- node_detach(name)
- else:
- root.error(message)
- else:
- node_detach(name)
- name := simple_name
- name += complex_name
- simple_name := '[a-zA-Z]+[a-zA-Z0-9]*'
- complex_name := '"([a-zA-Z]+[a-zA-Z0-9 ])*"':
- return args[1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement