
from __future__ import absolute_import

import click


def parse_page(page):
    """Parse the command man page."""
    with open(page) as f:
        lines = f.readlines()
    for line in lines:
        if line.startswith('#'):
            continue
        elif line.startswith('>'):
            click.secho(line.replace('>', ' '), fg='blue', nl=False)
        elif line.startswith('-'):
            click.secho(line, fg='green', nl=False)
        elif line.startswith('`'):
            click.secho('  ' + line.replace('`', ''), fg='cyan', nl=False)
        else:
            click.secho(line, nl=False)


from __future__ import absolute_import

import click

from tldr.config import get_config


def parse_page(page):
    """Parse the command man page."""
    colors = get_config()['colors']
    with open(page) as f:
        lines = f.readlines()
    for line in lines:
        if line.startswith('#'):
            continue
        elif line.startswith('>'):
            click.secho(line.replace('>', ' '), fg=colors['description'],
                        nl=False)
        elif line.startswith('-'):
            click.secho(line, fg=colors['usage'], nl=False)
        elif line.startswith('`'):
            click.secho('  ' + line.replace('`', ''), fg=colors['command'],
                        nl=False)
        else:
            click.secho(line, nl=False)

Use color configurations from config file
Use color configurations from config file

  
  from __future__ import absolute_import
  
  import click
  
+ from tldr.config import get_config
+ 
  
  def parse_page(page):
      """Parse the command man page."""
+     colors = get_config()['colors']
      with open(page) as f:
          lines = f.readlines()
      for line in lines:
          if line.startswith('#'):
              continue
          elif line.startswith('>'):
-             click.secho(line.replace('>', ' '), fg='blue', nl=False)
+             click.secho(line.replace('>', ' '), fg=colors['description'],
+                         nl=False)
          elif line.startswith('-'):
-             click.secho(line, fg='green', nl=False)
+             click.secho(line, fg=colors['usage'], nl=False)
          elif line.startswith('`'):
-             click.secho('  ' + line.replace('`', ''), fg='cyan', nl=False)
+             click.secho('  ' + line.replace('`', ''), fg=colors['command'],
+                         nl=False)
          else:
              click.secho(line, nl=False)
  
Use color configurations from config file
## Code Before:

from __future__ import absolute_import

import click


def parse_page(page):
    """Parse the command man page."""
    with open(page) as f:
        lines = f.readlines()
    for line in lines:
        if line.startswith('#'):
            continue
        elif line.startswith('>'):
            click.secho(line.replace('>', ' '), fg='blue', nl=False)
        elif line.startswith('-'):
            click.secho(line, fg='green', nl=False)
        elif line.startswith('`'):
            click.secho('  ' + line.replace('`', ''), fg='cyan', nl=False)
        else:
            click.secho(line, nl=False)

## Instruction:
Use color configurations from config file
## Code After:

from __future__ import absolute_import

import click

from tldr.config import get_config


def parse_page(page):
    """Parse the command man page."""
    colors = get_config()['colors']
    with open(page) as f:
        lines = f.readlines()
    for line in lines:
        if line.startswith('#'):
            continue
        elif line.startswith('>'):
            click.secho(line.replace('>', ' '), fg=colors['description'],
                        nl=False)
        elif line.startswith('-'):
            click.secho(line, fg=colors['usage'], nl=False)
        elif line.startswith('`'):
            click.secho('  ' + line.replace('`', ''), fg=colors['command'],
                        nl=False)
        else:
            click.secho(line, nl=False)
