-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Minor refactors to make function easier to move * Moves cli specific code to cli.js * Moves pdf, epub, html functions to index.js * Adds cli.js as bin in package.json * Fixes code of conduct change
- Loading branch information
Showing
4 changed files
with
82 additions
and
76 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,41 @@ | ||
#!/usr/bin/env node | ||
const program = require('commander'); | ||
const pkg = require('./package.json'); | ||
|
||
const { configure, pdf, epub, html } = require('.'); | ||
|
||
/* | ||
Some setup | ||
---------- | ||
*/ | ||
configure(); | ||
|
||
/* | ||
Command-Line Interface definition | ||
--------------------------------- | ||
*/ | ||
|
||
function with_common_options(cmd) { | ||
return cmd | ||
.option('-o, --output [output]', 'Path for the generated bundle') | ||
.option('--template [template]', 'Path to custom HTML template') | ||
.option('--style [stylesheet]', 'Path to custom CSS') | ||
.option('--css [style]', 'Additional CSS style'); | ||
} | ||
|
||
program.version(pkg.version); | ||
|
||
with_common_options(program.command('pdf [urls...]')) | ||
.option('--no-sandbox', 'Passed to Puppeteer') | ||
.description('Bundle web pages as a PDF file') | ||
.action(pdf); | ||
|
||
with_common_options(program.command('epub [urls...]')) | ||
.description('Bundle web pages as an EPUB file') | ||
.action(epub); | ||
|
||
with_common_options(program.command('html [urls...]')) | ||
.description('Bundle web pages as a HTML file') | ||
.action(html); | ||
|
||
program.parse(process.argv); |
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