Skip to content

Commit

Permalink
feat: syntax highlighting on example snippet (#795)
Browse files Browse the repository at this point in the history
* feat: syntax highlighting on example snippet

* chore: small stylistic change
  • Loading branch information
kanadgupta authored Oct 26, 2023
1 parent f93f152 commit 16a402b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
54 changes: 49 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@readme/openapi-parser": "^2.4.0",
"chalk": "^5.3.0",
"commander": "^11.1.0",
"emphasize": "^6.0.0",
"execa": "^8.0.1",
"figures": "^5.0.0",
"httpsnippet-client-api": "file:../httpsnippet-client-api",
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { SupportedLanguage } from '../codegen/factory.js';

import chalk from 'chalk';
import { Command, Option } from 'commander';
import { emphasize } from 'emphasize';
import figures from 'figures';
import Oas from 'oas';
import ora from 'ora';
Expand Down Expand Up @@ -222,10 +223,11 @@ cmd
const exampleSnippet = await getExampleCodeSnippet(oas, identifier);
if (exampleSnippet) {
logger('');
logger("Here's an example code snippet you can try out:");
logger(chalk.bold("👇 Here's an example code snippet you can try out 👇"));
logger('');
logger(chalk.green(exampleSnippet));
logger(emphasize.highlight(language, exampleSnippet).value);
}
logger('');
})
.addHelpText(
'after',
Expand Down

0 comments on commit 16a402b

Please sign in to comment.