2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 02:28: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) {
program
.version(packageJson.version)
.arguments('<targetUrl> [appDir]')
.arguments('<targetUrl> [dest]')
.action(function (targetUrl, appDir) {
program.targetUrl = targetUrl;
program.outDir = appDir;
})
.option('-n, --appName [value]', 'app name')
.option('-p, --platform [platform]', '\'linux\', \'win32\', or \'darwin\'')
.option('-a, --arch [architecture]', '\'ia32\' or \'x64\'')
.option('-e, --electron-version', '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('-n, --app-name <value>', 'app name')
.option('-p, --platform <value>', '\'linux\', \'win32\', or \'darwin\'')
.option('-a, --arch <value>', '\'ia32\' or \'x64\'')
.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 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('-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('-w, --width [value]', 'set window width, defaults to 1280px')
.option('-h, --height [value]', 'set window height, defaults to 800px')
.option('-i, --icon <value>', 'the icon file to use as the icon for the app (should be a .icns file on OSX)')
.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);
if (!process.argv.slice(2).length) {

View File

@ -15,7 +15,7 @@ function optionsFactory(name,
arch = detectArch(),
version = ELECTRON_VERSION,
outDir = process.cwd(),
overwrite = true,
overwrite = false,
conceal = false,
icon,
badge = false,
@ -23,7 +23,15 @@ function optionsFactory(name,
height = 800, callback) {
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 = {