
import click


@click.group()
def cli():
    pass

@cli.command()
def version():
    click.echo("You are using ofcourse version {}".format(__version__))
    click.echo("Get more information at "
               "https://github.com/ryansb/ofCourse")


@cli.command(short_help="Push this to openshift. Requires "
             "http://openshift.com account. Will check for "
             "course.openshift.git_url as well as CLI flag --remote")
@click.option("-o", "--output", help="File to send output to")
@click.option("--stdout", help="Sent output to stdout instead", is_flag=True)
def md(output, stdout):
    pass


import click

from bookmarkd.version import __version__
from bookmarkd.to_notebook import to_notebook as md_to_nb


@click.group()
def cli():
    pass


@cli.command()
def version():
    click.echo("You are using bookmarkd version {}".format(__version__))
    click.echo("Get more information at "
               "https://github.com/ryansb/bookmarkd")


@cli.command(short_help="Do the conversion")
@click.argument("infile", type=click.File('rb'))
@click.argument("outfile", type=click.File('wb'))
def convert(infile, outfile):
    if infile.name.endswith('.md'):
        pynb = md_to_nb(infile)
        outfile.write(pynb)

    else:
        click.echo("Only markdown -> notebook conversion is "
                   "currently supported")

Make convert command work with files or stdin/out
Make convert command work with files or stdin/out

  
  import click
+ 
+ from bookmarkd.version import __version__
+ from bookmarkd.to_notebook import to_notebook as md_to_nb
  
  
  @click.group()
  def cli():
      pass
  
+ 
  @cli.command()
  def version():
-     click.echo("You are using ofcourse version {}".format(__version__))
+     click.echo("You are using bookmarkd version {}".format(__version__))
      click.echo("Get more information at "
-                "https://github.com/ryansb/ofCourse")
+                "https://github.com/ryansb/bookmarkd")
  
  
- @cli.command(short_help="Push this to openshift. Requires "
-              "http://openshift.com account. Will check for "
-              "course.openshift.git_url as well as CLI flag --remote")
- @click.option("-o", "--output", help="File to send output to")
- @click.option("--stdout", help="Sent output to stdout instead", is_flag=True)
- def md(output, stdout):
-     pass
+ @cli.command(short_help="Do the conversion")
+ @click.argument("infile", type=click.File('rb'))
+ @click.argument("outfile", type=click.File('wb'))
+ def convert(infile, outfile):
+     if infile.name.endswith('.md'):
+         pynb = md_to_nb(infile)
+         outfile.write(pynb)
  
+     else:
+         click.echo("Only markdown -> notebook conversion is "
+                    "currently supported")
+ 
Make convert command work with files or stdin/out
## Code Before:

import click


@click.group()
def cli():
    pass

@cli.command()
def version():
    click.echo("You are using ofcourse version {}".format(__version__))
    click.echo("Get more information at "
               "https://github.com/ryansb/ofCourse")


@cli.command(short_help="Push this to openshift. Requires "
             "http://openshift.com account. Will check for "
             "course.openshift.git_url as well as CLI flag --remote")
@click.option("-o", "--output", help="File to send output to")
@click.option("--stdout", help="Sent output to stdout instead", is_flag=True)
def md(output, stdout):
    pass

## Instruction:
Make convert command work with files or stdin/out
## Code After:

import click

from bookmarkd.version import __version__
from bookmarkd.to_notebook import to_notebook as md_to_nb


@click.group()
def cli():
    pass


@cli.command()
def version():
    click.echo("You are using bookmarkd version {}".format(__version__))
    click.echo("Get more information at "
               "https://github.com/ryansb/bookmarkd")


@cli.command(short_help="Do the conversion")
@click.argument("infile", type=click.File('rb'))
@click.argument("outfile", type=click.File('wb'))
def convert(infile, outfile):
    if infile.name.endswith('.md'):
        pynb = md_to_nb(infile)
        outfile.write(pynb)

    else:
        click.echo("Only markdown -> notebook conversion is "
                   "currently supported")
