code: def complete_rule(rule, cmd):
      '''complete using one rule'''
      global rline_mpstate
      rule_components = rule.split(' ')
  
      #  complete the empty string (e.g "graph <TAB><TAB>")
      if len(cmd) == 0:
          return rule_expand(rule_components[0], "")
  
      # check it matches so far
      for i in range(len(cmd)-1):
          if not rule_match(rule_components[i], cmd[i]):
              return []
  
      # expand the next rule component
      expanded = rule_expand(rule_components[len(cmd)-1], cmd[-1])
      return expandef complete_rule(rule, cmd):
      '''complete using one rule'''
      global rline_mpstate
      rule_components = rule.split(' ')
  
      #  complete the empty string (e.g "graph <TAB><TAB>")
      if len(cmd) == 0:
          return rule_expand(rule_components[0], "")
  
      # check it matches so far
      for i in range(len(cmd)-1):
          if not rule_match(rule_components[i], cmd[i]):
              return []
  
      # expand the next rule component
      expanded = rule_expand(rule_components[len(cmd)-1], cmd[-1])
      return expanded
docs: complete using one rule