
import click

from rnacentral_pipeline.rnacentral.genes import build, write


@click.group("genes")
def cli():
    """
    A group of commands dealing with building genes.
    """
    pass


@cli.command("build")
@click.option("--format", type=click.Choice(write.Format.names(), case_sensitive=False))
@click.argument("data_file", type=click.File("r"))
@click.argument("output", type=click.File("w"))
def build_genes(data_file, output, format=None):
    """
    Build the genes for the given data file. This assumes that the file is
    already split into reasonable chunks.
    """
    data = build.from_json(data_file)
    write.write(data, write.Format.from_name(format), output)


import click

from rnacentral_pipeline.rnacentral.genes import build, write


@click.group("genes")
def cli():
    """
    A group of commands dealing with building genes.
    """
    pass


@cli.command("build")
@click.option(
    "--format",
    default="csv",
    type=click.Choice(write.Format.names(), case_sensitive=False),
)
@click.argument("data_file", type=click.File("r"))
@click.argument("output", type=click.File("w"))
def build_genes(data_file, output, format=None):
    """
    Build the genes for the given data file. The file can contain all data for a
    specific assembly.
    """
    data = build.from_json(data_file)
    write.write(data, write.Format.from_name(format), output)

Clean up CLI a bit
Clean up CLI a bit

Default arguments are useful.

  
  import click
  
  from rnacentral_pipeline.rnacentral.genes import build, write
  
  
  @click.group("genes")
  def cli():
      """
      A group of commands dealing with building genes.
      """
      pass
  
  
  @cli.command("build")
+ @click.option(
+     "--format",
+     default="csv",
- @click.option("--format", type=click.Choice(write.Format.names(), case_sensitive=False))
+     type=click.Choice(write.Format.names(), case_sensitive=False),
+ )
  @click.argument("data_file", type=click.File("r"))
  @click.argument("output", type=click.File("w"))
  def build_genes(data_file, output, format=None):
      """
-     Build the genes for the given data file. This assumes that the file is
-     already split into reasonable chunks.
+     Build the genes for the given data file. The file can contain all data for a
+     specific assembly.
      """
      data = build.from_json(data_file)
      write.write(data, write.Format.from_name(format), output)
  
Clean up CLI a bit
## Code Before:

import click

from rnacentral_pipeline.rnacentral.genes import build, write


@click.group("genes")
def cli():
    """
    A group of commands dealing with building genes.
    """
    pass


@cli.command("build")
@click.option("--format", type=click.Choice(write.Format.names(), case_sensitive=False))
@click.argument("data_file", type=click.File("r"))
@click.argument("output", type=click.File("w"))
def build_genes(data_file, output, format=None):
    """
    Build the genes for the given data file. This assumes that the file is
    already split into reasonable chunks.
    """
    data = build.from_json(data_file)
    write.write(data, write.Format.from_name(format), output)

## Instruction:
Clean up CLI a bit
## Code After:

import click

from rnacentral_pipeline.rnacentral.genes import build, write


@click.group("genes")
def cli():
    """
    A group of commands dealing with building genes.
    """
    pass


@cli.command("build")
@click.option(
    "--format",
    default="csv",
    type=click.Choice(write.Format.names(), case_sensitive=False),
)
@click.argument("data_file", type=click.File("r"))
@click.argument("output", type=click.File("w"))
def build_genes(data_file, output, format=None):
    """
    Build the genes for the given data file. The file can contain all data for a
    specific assembly.
    """
    data = build.from_json(data_file)
    write.write(data, write.Format.from_name(format), output)
