Skip to content

Commit 61588cf

Browse files
committed
Add diff function for runbooks
1 parent 7738a15 commit 61588cf

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

runbook/cli/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
check,
66
convert,
77
create,
8+
diff,
89
edit,
910
export,
1011
init,
@@ -39,6 +40,7 @@ def cli(ctx, cwd):
3940
cli.add_command(create)
4041
cli.add_command(convert)
4142
cli.add_command(check)
43+
cli.add_command(diff)
4244
cli.add_command(run)
4345
cli.add_command(review)
4446
cli.add_command(version)

runbook/cli/commands/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from runbook.cli.commands.check import check
22
from runbook.cli.commands.convert import convert
33
from runbook.cli.commands.create import create
4+
from runbook.cli.commands.diff import diff
45
from runbook.cli.commands.edit import edit
56
from runbook.cli.commands.init import init
67
from runbook.cli.commands.plan import plan

runbook/cli/commands/diff.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from os import path
2+
3+
import click
4+
from runbook.cli.completions import EditableNotebook
5+
from runbook.cli.validators import validate_runbook_file_path
6+
7+
@click.command()
8+
@click.argument(
9+
"notebook_1",
10+
type=EditableNotebook(file_okay=True),
11+
callback=validate_runbook_file_path,
12+
)
13+
@click.argument(
14+
"notebook_2",
15+
type=EditableNotebook(file_okay=True),
16+
callback=validate_runbook_file_path,
17+
)
18+
19+
@click.pass_context
20+
def diff(ctx, notebook_1, notebook_2):
21+
"""Convert an existing runbook to different format"""
22+
argv = [path.abspath(notebook_1), path.abspath(notebook_2)]
23+
from nbdime import nbdiffapp
24+
25+
nbdiffapp.main(args=argv)

0 commit comments

Comments
 (0)