nodes: 0, module; 1, function_definition; 2, function_name:print_all_commands; 3, parameters; 4, block; 5, identifier:self; 6, keyword_separator; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, for_statement; 14, if_statement; 15, identifier:no_pager; 16, False; 17, comment:"""Print help for all commands.
  
          Commands are sorted in alphabetical order and wrapping is done
          based on the width of the terminal.
          """; 18, assignment; 19, assignment; 20, assignment; 21, assignment; 22, identifier:name; 23, identifier:command_names; 24, block; 25, identifier:no_pager; 26, block; 27, else_clause; 28, identifier:formatter; 29, call; 30, identifier:command_names; 31, call; 32, identifier:max_name_len; 33, binary_operator:max([len(name) for name in command_names]) + 1; 34, identifier:commands; 35, string:""; 36, expression_statement; 37, expression_statement; 38, expression_statement; 39, while_statement; 40, if_statement; 41, expression_statement; 42, block; 43, attribute; 44, argument_list; 45, identifier:sorted; 46, argument_list; 47, call; 48, integer:1; 49, assignment; 50, assignment; 51, assignment; 52, comparison_operator:len(command_line) > formatter._width; 53, block; 54, identifier:command_line; 55, block; 56, call; 57, expression_statement; 58, attribute; 59, identifier:_get_formatter; 60, call; 61, identifier:max; 62, argument_list; 63, identifier:command; 64, subscript; 65, identifier:extra_padding; 66, binary_operator:max_name_len - len(name); 67, identifier:command_line; 68, binary_operator:'%s%s%s' % (
                  name, ' ' * extra_padding, command.description); 69, call; 70, attribute; 71, expression_statement; 72, expression_statement; 73, if_statement; 74, expression_statement; 75, identifier:print; 76, argument_list; 77, call; 78, identifier:self; 79, identifier:parent_parser; 80, attribute; 81, argument_list; 82, list_comprehension; 83, attribute; 84, identifier:name; 85, identifier:max_name_len; 86, call; 87, string; 88, tuple; 89, identifier:len; 90, argument_list; 91, identifier:formatter; 92, identifier:_width; 93, assignment; 94, augmented_assignment; 95, comparison_operator:len(lines) > 1; 96, block; 97, else_clause; 98, augmented_assignment; 99, subscript; 100, identifier:print_with_pager; 101, argument_list; 102, attribute; 103, identifier:keys; 104, call; 105, for_in_clause; 106, attribute; 107, identifier:choices; 108, identifier:len; 109, argument_list; 110, string_content:%s%s%s; 111, identifier:name; 112, binary_operator:' ' * extra_padding; 113, attribute; 114, identifier:command_line; 115, identifier:lines; 116, call; 117, identifier:commands; 118, binary_operator:"%s\n" % lines[0]; 119, call; 120, integer:1; 121, expression_statement; 122, expression_statement; 123, block; 124, identifier:commands; 125, binary_operator:"%s\n" % command_line; 126, identifier:commands; 127, slice; 128, subscript; 129, attribute; 130, identifier:choices; 131, identifier:len; 132, argument_list; 133, identifier:name; 134, identifier:command_names; 135, attribute; 136, identifier:subparsers; 137, identifier:name; 138, string; 139, identifier:extra_padding; 140, identifier:command; 141, identifier:description; 142, attribute; 143, argument_list; 144, string:"%s\n"; 145, subscript; 146, identifier:len; 147, argument_list; 148, assignment; 149, assignment; 150, expression_statement; 151, string:"%s\n"; 152, identifier:command_line; 153, unary_operator; 154, identifier:commands; 155, slice; 156, attribute; 157, identifier:subparsers; 158, identifier:name; 159, identifier:self; 160, identifier:parent_parser; 161, string_content:; 162, identifier:textwrap; 163, identifier:wrap; 164, identifier:command_line; 165, attribute; 166, identifier:lines; 167, integer:0; 168, identifier:lines; 169, subscript; 170, binary_operator:(' ' * max_name_len) + lines[1]; 171, identifier:command_line; 172, call; 173, assignment; 174, integer:1; 175, unary_operator; 176, identifier:self; 177, identifier:parent_parser; 178, identifier:formatter; 179, identifier:_width; 180, identifier:lines; 181, integer:1; 182, parenthesized_expression; 183, subscript; 184, attribute; 185, argument_list; 186, identifier:command_line; 187, None; 188, integer:1; 189, binary_operator:' ' * max_name_len; 190, identifier:lines; 191, integer:1; 192, string; 193, identifier:join; 194, subscript; 195, string; 196, identifier:max_name_len; 197, string_content:; 198, identifier:lines; 199, slice; 200, string_content:; 201, integer:1
code: def print_all_commands(self, *, no_pager=False):
          """Print help for all commands.
  
          Commands are sorted in alphabetical order and wrapping is done
          based on the width of the terminal.
          """
          formatter = self.parent_parser._get_formatter()
          command_names = sorted(self.parent_parser.subparsers.choices.keys())
          max_name_len = max([len(name) for name in command_names]) + 1
          commands = ""
          for name in command_names:
              command = self.parent_parser.subparsers.choices[name]
              extra_padding = max_name_len - len(name)
              command_line = '%s%s%s' % (
                  name, ' ' * extra_padding, command.description)
              while len(command_line) > formatter._width:
                  lines = textwrap.wrap(command_line, formatter._width)
                  commands += "%s\n" % lines[0]
                  if len(lines) > 1:
                      lines[1] = (' ' * max_name_len) + lines[1]
                      command_line = ' '.join(lines[1:])
                  else:
                      command_line = None
              if command_line:
                  commands += "%s\n" % command_line
          if no_pager:
              print(commands[:-1])
          else:
              print_with_pager(commands[:-1])