"""Generate files from Jinja2 templates and environment variables."""

from __future__ import (
    absolute_import,
    division,
    print_function,
    unicode_literals,
)  # pylint: disable=duplicate-code
from os import environ
from sys import stdin, stdout
import argparse
from argparse import ArgumentParser
from jinja2 import Environment
import template.filters


__version__ = "0.6.4"


def render(template_string):
    """Render the template."""
    env = Environment(autoescape=True)
    # Add all functions in template.filters as Jinja filters.
    # pylint: disable=invalid-name
    for tf in filter(lambda x: not x.startswith("_"), dir(template.filters)):
        env.filters[tf] = getattr(template.filters, tf)
    t = env.from_string(template_string)
    return t.render(environ)


def main():
    """Main entrypoint."""
    parser = ArgumentParser(
        description="""A CLI tool for generating files from Jinja2 templates
        and environment variables."""
    )
    parser.add_argument(
        "filename",
        help="Input filename",
        type=argparse.FileType("r"),
        nargs="?",
    )
    parser.add_argument(
        "-o",
        "--output",
        help="Output to filename",
        type=argparse.FileType("w"),
    )
    args = parser.parse_args()
    infd = args.filename if args.filename else stdin
    outfd = args.output if args.output else stdout
    print(render(infd.read()), file=outfd)


if __name__ == "__main__":
    main()


from __future__ import (
    absolute_import,
    division,
    print_function,
    unicode_literals,
)  # pylint: disable=duplicate-code
from os import environ
from sys import stdin, stdout
import argparse
from argparse import ArgumentParser
from jinja2 import Environment
import template.filters


__version__ = "0.6.4"


def render(template_string):
    """Render the template."""
    env = Environment(autoescape=True)
    # Add all functions in template.filters as Jinja filters.
    # pylint: disable=invalid-name
    for tf in filter(lambda x: not x.startswith("_"), dir(template.filters)):
        env.filters[tf] = getattr(template.filters, tf)
    t = env.from_string(template_string)
    return t.render(environ)


def main():
    """Main entrypoint."""
    parser = ArgumentParser(description=__doc__)
    parser.add_argument(
        "filename",
        help="Input filename",
        type=argparse.FileType("r"),
        nargs="?",
    )
    parser.add_argument(
        "-o",
        "--output",
        help="Output to filename",
        type=argparse.FileType("w"),
    )
    args = parser.parse_args()
    infd = args.filename if args.filename else stdin
    outfd = args.output if args.output else stdout
    print(render(infd.read()), file=outfd)


if __name__ == "__main__":
    main()

Use the docstring as the CLI description.
Use the docstring as the CLI description.

- """Generate files from Jinja2 templates and environment variables."""
  
  from __future__ import (
      absolute_import,
      division,
      print_function,
      unicode_literals,
  )  # pylint: disable=duplicate-code
  from os import environ
  from sys import stdin, stdout
  import argparse
  from argparse import ArgumentParser
  from jinja2 import Environment
  import template.filters
  
  
  __version__ = "0.6.4"
  
  
  def render(template_string):
      """Render the template."""
      env = Environment(autoescape=True)
      # Add all functions in template.filters as Jinja filters.
      # pylint: disable=invalid-name
      for tf in filter(lambda x: not x.startswith("_"), dir(template.filters)):
          env.filters[tf] = getattr(template.filters, tf)
      t = env.from_string(template_string)
      return t.render(environ)
  
  
  def main():
      """Main entrypoint."""
+     parser = ArgumentParser(description=__doc__)
-     parser = ArgumentParser(
-         description="""A CLI tool for generating files from Jinja2 templates
-         and environment variables."""
-     )
      parser.add_argument(
          "filename",
          help="Input filename",
          type=argparse.FileType("r"),
          nargs="?",
      )
      parser.add_argument(
          "-o",
          "--output",
          help="Output to filename",
          type=argparse.FileType("w"),
      )
      args = parser.parse_args()
      infd = args.filename if args.filename else stdin
      outfd = args.output if args.output else stdout
      print(render(infd.read()), file=outfd)
  
  
  if __name__ == "__main__":
      main()
  
Use the docstring as the CLI description.
## Code Before:
"""Generate files from Jinja2 templates and environment variables."""

from __future__ import (
    absolute_import,
    division,
    print_function,
    unicode_literals,
)  # pylint: disable=duplicate-code
from os import environ
from sys import stdin, stdout
import argparse
from argparse import ArgumentParser
from jinja2 import Environment
import template.filters


__version__ = "0.6.4"


def render(template_string):
    """Render the template."""
    env = Environment(autoescape=True)
    # Add all functions in template.filters as Jinja filters.
    # pylint: disable=invalid-name
    for tf in filter(lambda x: not x.startswith("_"), dir(template.filters)):
        env.filters[tf] = getattr(template.filters, tf)
    t = env.from_string(template_string)
    return t.render(environ)


def main():
    """Main entrypoint."""
    parser = ArgumentParser(
        description="""A CLI tool for generating files from Jinja2 templates
        and environment variables."""
    )
    parser.add_argument(
        "filename",
        help="Input filename",
        type=argparse.FileType("r"),
        nargs="?",
    )
    parser.add_argument(
        "-o",
        "--output",
        help="Output to filename",
        type=argparse.FileType("w"),
    )
    args = parser.parse_args()
    infd = args.filename if args.filename else stdin
    outfd = args.output if args.output else stdout
    print(render(infd.read()), file=outfd)


if __name__ == "__main__":
    main()

## Instruction:
Use the docstring as the CLI description.
## Code After:

from __future__ import (
    absolute_import,
    division,
    print_function,
    unicode_literals,
)  # pylint: disable=duplicate-code
from os import environ
from sys import stdin, stdout
import argparse
from argparse import ArgumentParser
from jinja2 import Environment
import template.filters


__version__ = "0.6.4"


def render(template_string):
    """Render the template."""
    env = Environment(autoescape=True)
    # Add all functions in template.filters as Jinja filters.
    # pylint: disable=invalid-name
    for tf in filter(lambda x: not x.startswith("_"), dir(template.filters)):
        env.filters[tf] = getattr(template.filters, tf)
    t = env.from_string(template_string)
    return t.render(environ)


def main():
    """Main entrypoint."""
    parser = ArgumentParser(description=__doc__)
    parser.add_argument(
        "filename",
        help="Input filename",
        type=argparse.FileType("r"),
        nargs="?",
    )
    parser.add_argument(
        "-o",
        "--output",
        help="Output to filename",
        type=argparse.FileType("w"),
    )
    args = parser.parse_args()
    infd = args.filename if args.filename else stdin
    outfd = args.output if args.output else stdout
    print(render(infd.read()), file=outfd)


if __name__ == "__main__":
    main()
