Example #1
0
 def testHelpTextUnderlineFlag(self):
     component = tc.WithDefaults().triple
     t = trace.FireTrace(component, name="triple")
     help_screen = helptext.HelpText(component, t)
     self.assertIn(formatting.Bold("NAME") + "\n    triple", help_screen)
     self.assertIn(formatting.Bold("SYNOPSIS") + "\n    triple <flags>", help_screen)
     self.assertIn(
         formatting.Bold("FLAGS") + "\n    --" + formatting.Underline("count"),
         help_screen,
     )
Example #2
0
 def testHelpTextUnderlineFlag(self):
     component = tc.WithDefaults().triple
     t = trace.FireTrace(component, name='triple')
     help_screen = helptext.HelpText(component, t)
     self.assertIn(formatting.Bold('NAME') + '\n    triple', help_screen)
     self.assertIn(
         formatting.Bold('SYNOPSIS') + '\n    triple <flags>', help_screen)
     self.assertIn(
         formatting.Bold('FLAGS') + '\n    --' +
         formatting.Underline('count'), help_screen)
Example #3
0
 def testHelpTextBoldCommandName(self):
     component = tc.ClassWithDocstring()
     t = trace.FireTrace(component, name='ClassWithDocstring')
     help_screen = helptext.HelpText(component, t)
     self.assertIn(
         formatting.Bold('NAME') + '\n    ClassWithDocstring', help_screen)
     self.assertIn(formatting.Bold('COMMANDS') + '\n', help_screen)
     self.assertIn(
         formatting.BoldUnderline('COMMAND') +
         ' is one of the following:\n', help_screen)
     self.assertIn(formatting.Bold('print_msg') + '\n', help_screen)
Example #4
0
 def testHelpTextBoldCommandName(self):
     component = tc.ClassWithDocstring()
     t = trace.FireTrace(component, name="ClassWithDocstring")
     help_screen = helptext.HelpText(component, t)
     self.assertIn(formatting.Bold("NAME") + "\n    ClassWithDocstring", help_screen)
     self.assertIn(formatting.Bold("COMMANDS") + "\n", help_screen)
     self.assertIn(
         formatting.BoldUnderline("COMMAND") + " is one of the following:\n",
         help_screen,
     )
     self.assertIn(formatting.Bold("print_msg") + "\n", help_screen)
Example #5
0
 def testHelpTextUnderlineFlag(self):
     component = tc.WithDefaults().triple
     info = inspectutils.Info(component)
     t = trace.FireTrace(component, name='triple')
     help_screen = helptext.HelpText(component, info, t)
     self.assertIn(formatting.Bold('NAME') + '\n    triple', help_screen)
     self.assertIn(
         formatting.Bold('SYNOPSIS') + '\n    triple [--count=COUNT]',
         help_screen)
     self.assertIn(
         formatting.Bold('FLAGS') + '\n    --' +
         formatting.Underline('count'), help_screen)
Example #6
0
def CommandUsageDetailsSection(commands):
    """Creates a section tuple for the commands section of the usage details."""
    command_item_strings = []
    for command_name, command in commands:
        command_info = inspectutils.Info(command)
        command_item = formatting.Bold(command_name)
        if 'docstring_info' in command_info:
            command_docstring_info = command_info['docstring_info']
            if command_docstring_info and command_docstring_info.summary:
                command_item = _CreateItem(formatting.Bold(command_name),
                                           command_docstring_info.summary)
        command_item_strings.append(command_item)
    return ('COMMANDS', _NewChoicesSection('COMMAND', command_item_strings))
Example #7
0
def _NewChoicesSection(name, choices):
    return _CreateItem(
        "{name} is one of the following:".format(
            name=formatting.Bold(formatting.Underline(name))),
        "\n" + "\n\n".join(choices),
        indent=1,
    )
Example #8
0
def _NewChoicesSection(name, choices):
  return _CreateItem(
      '{name} is one of the following:'.format(
          name=formatting.Bold(formatting.Underline(name))),
      '\n' + '\n\n'.join(choices),
      indent=1)
Example #9
0
def _CreateOutputSection(name, content):
  return """{name}
{content}""".format(name=formatting.Bold(name),
                    content=formatting.Indent(content, 4))
 def test_bold(self):
   text = formatting.Bold('hello')
   self.assertEqual('\x1b[1mhello\x1b[0m', text)
Example #11
0
 def test_bold(self):
     text = formatting.Bold("hello")
     self.assertEqual("\x1b[1mhello\x1b[0m", text)