2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 18:48:55 +00:00

Make help text clearer, add parsing of width and height

This commit is contained in:
Jia Hao 2016-01-19 01:17:12 +08:00
parent 549427c8ac
commit e12d10042c
2 changed files with 19 additions and 11 deletions

View File

@ -44,21 +44,21 @@ function main(program) {
if (require.main === module) { if (require.main === module) {
program program
.version(packageJson.version) .version(packageJson.version)
.arguments('<targetUrl> [appDir]') .arguments('<targetUrl> [dest]')
.action(function (targetUrl, appDir) { .action(function (targetUrl, appDir) {
program.targetUrl = targetUrl; program.targetUrl = targetUrl;
program.outDir = appDir; program.outDir = appDir;
}) })
.option('-n, --appName [value]', 'app name') .option('-n, --app-name <value>', 'app name')
.option('-p, --platform [platform]', '\'linux\', \'win32\', or \'darwin\'') .option('-p, --platform <value>', '\'linux\', \'win32\', or \'darwin\'')
.option('-a, --arch [architecture]', '\'ia32\' or \'x64\'') .option('-a, --arch <value>', '\'ia32\' or \'x64\'')
.option('-e, --electron-version', 'electron version to package, without the \'v\', see https://github.com/atom/electron/releases') .option('-e, --electron-version <value>', 'electron version to package, without the \'v\', see https://github.com/atom/electron/releases')
.option('-o, --overwrite', 'if output directory for a platform already exists, replaces it rather than skipping it, defaults to true') .option('-o, --overwrite', 'if output directory for a platform already exists, replaces it rather than skipping it, defaults to false')
.option('-c, --conceal', 'packages the source code within your app into an archive, defaults to false, see http://electron.atom.io/docs/v0.36.0/tutorial/application-packaging/') .option('-c, --conceal', 'packages the source code within your app into an archive, defaults to false, see http://electron.atom.io/docs/v0.36.0/tutorial/application-packaging/')
.option('-i, --icon [dir]', 'the icon file to use as the icon for the app (should be a .icns file on OSX)')
.option('-b, --badge', 'if the target app should show badges in the dock on receipt of desktop notifications (OSX only), defaults to false') .option('-b, --badge', 'if the target app should show badges in the dock on receipt of desktop notifications (OSX only), defaults to false')
.option('-w, --width [value]', 'set window width, defaults to 1280px') .option('-i, --icon <value>', 'the icon file to use as the icon for the app (should be a .icns file on OSX)')
.option('-h, --height [value]', 'set window height, defaults to 800px') .option('-w, --width <value>', 'set window width, defaults to 1280px', parseInt)
.option('-h, --height <value>', 'set window height, defaults to 800px', parseInt)
.parse(process.argv); .parse(process.argv);
if (!process.argv.slice(2).length) { if (!process.argv.slice(2).length) {

View File

@ -15,7 +15,7 @@ function optionsFactory(name,
arch = detectArch(), arch = detectArch(),
version = ELECTRON_VERSION, version = ELECTRON_VERSION,
outDir = process.cwd(), outDir = process.cwd(),
overwrite = true, overwrite = false,
conceal = false, conceal = false,
icon, icon,
badge = false, badge = false,
@ -23,7 +23,15 @@ function optionsFactory(name,
height = 800, callback) { height = 800, callback) {
if (!validator.isURL(targetUrl, {require_protocol: true})) { if (!validator.isURL(targetUrl, {require_protocol: true})) {
throw 'Your Url is invalid!, did you remember to include \'http://\'?'; throw `Your Url ${targetUrl} is invalid!, did you remember to include 'http://'?`;
}
if (!width) {
width = 1280;
}
if (!height) {
height = 800;
} }
const options = { const options = {