Skip to content

Commit

Permalink
[Update] add option to debug summary command
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Huang <[email protected]>
  • Loading branch information
kentwelcome committed Apr 26, 2024
1 parent 23e5e4d commit 8294189
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions recce/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def run(output, **kwargs):

@cli.command(cls=TrackCommand)
@click.argument('state_file', required=True)
@click.option('--format', '-f', help='Output format. Currently only markdown is supported.',
type=click.Choice(['markdown', 'mermaid'], case_sensitive=False),
default='markdown', show_default=True)
def summary(state_file, **kwargs):
from rich.console import Console
from .core import load_context
Expand All @@ -203,8 +206,8 @@ def summary(state_file, **kwargs):
console.print(f"{e}")
exit(1)

markdown = generate_markdown_summary(ctx)
console.print(markdown)
output = generate_markdown_summary(ctx, summary_format=kwargs.get('format'))
console.print(output)


if __name__ == "__main__":
Expand Down
10 changes: 8 additions & 2 deletions recce/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,19 @@ def generate_mermaid_lineage_graph(graph: LineageGraph):
return content


def generate_markdown_summary(ctx):
def generate_markdown_summary(ctx, summary_format: str = 'markdown'):
curr_lineage = ctx.get_lineage(base=False)
base_lineage = ctx.get_lineage(base=True)
graph = _build_lineage_graph(base_lineage, curr_lineage)
mermaid_content = generate_mermaid_lineage_graph(graph)
return f'''

if summary_format == 'mermaid':
return mermaid_content
elif summary_format == 'markdown':
return f'''
# Recce Summary
## Lineage Graph
```mermaid
{mermaid_content}
```
Expand Down

0 comments on commit 8294189

Please sign in to comment.