import click

from twelve_tone.composer import Composer


@click.command()
def main():
    c = Composer()
    c.compose()
    click.echo(c.get_melody())

import click

from twelve_tone.composer import Composer


@click.command()
@click.option('--midi', '-m', help='MIDI output file')
def main(midi):
    c = Composer()
    c.compose()
    click.echo(c.get_melody())
    if midi is not None:
      c.save_to_midi(filename=midi)

Add --midi option to CLI
Add --midi option to CLI

  import click
  
  from twelve_tone.composer import Composer
  
  
  @click.command()
+ @click.option('--midi', '-m', help='MIDI output file')
- def main():
+ def main(midi):
      c = Composer()
      c.compose()
      click.echo(c.get_melody())
+     if midi is not None:
+       c.save_to_midi(filename=midi)
  
Add --midi option to CLI
## Code Before:
import click

from twelve_tone.composer import Composer


@click.command()
def main():
    c = Composer()
    c.compose()
    click.echo(c.get_melody())

## Instruction:
Add --midi option to CLI
## Code After:
import click

from twelve_tone.composer import Composer


@click.command()
@click.option('--midi', '-m', help='MIDI output file')
def main(midi):
    c = Composer()
    c.compose()
    click.echo(c.get_melody())
    if midi is not None:
      c.save_to_midi(filename=midi)
