-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba14493
commit 34b2eac
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import chalk from 'chalk' | ||
import { Command, Env, format, HelpError } from '@prisma/cli' | ||
import open from 'open' | ||
import terminalLink from 'terminal-link' | ||
import { link } from './link' | ||
|
||
/** | ||
* $ prisma COMMAND_NAME docs | ||
*/ | ||
export class Docs implements Command { | ||
public static new(commandName: string, url: string): Docs { | ||
return new Docs(commandName, url) | ||
} | ||
|
||
// static help template | ||
private static help = commandName => | ||
format(` | ||
Opens the docs page for ${commandName}. | ||
`) | ||
private constructor(private readonly commandName: string, private readonly url: string) {} | ||
|
||
// parse arguments | ||
public async parse(argv: string[]): Promise<string | Error> { | ||
console.log(`Opening ${chalk.greenBright(this.commandName)} docs at ${link(this.url)}`) | ||
await open(this.url) | ||
return '' | ||
} | ||
|
||
// help message | ||
public help(error?: string): string | HelpError { | ||
if (error) { | ||
return new HelpError(`\n${chalk.bold.red(`!`)} ${error}\n${Docs.help}`) | ||
} | ||
return Docs.help(this.commandName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import terminalLink from 'terminal-link' | ||
import chalk from 'chalk' | ||
|
||
export function link(url) { | ||
return terminalLink(url, url, { | ||
fallback: url => chalk.underline(url), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters