🎨 Optimizing the user prompts during command usage

This commit is contained in:
Tw93
2023-03-02 17:47:19 +08:00
parent fe754f663e
commit 129893c539
6 changed files with 9 additions and 9 deletions

8
bin/cli.ts vendored
View File

@@ -9,20 +9,20 @@ import { checkUpdateTips } from './helpers/updater.js';
// @ts-expect-error // @ts-expect-error
import packageJson from '../package.json'; import packageJson from '../package.json';
program.version(packageJson.version).description('A cli application can turn any webpage into a desktop app with Rust.'); program.version(packageJson.version).description('A command-line tool that can quickly convert a webpage into a desktop application.');
program program
.showHelpAfterError() .showHelpAfterError()
.argument('[url]', 'the web url you want to package', validateUrlInput) .argument('[url]', 'the web URL you want to package', validateUrlInput)
.option('-n, --name <string>', 'application name') .option('-n, --name <string>', 'application name')
.option('-i, --icon <string>', 'application icon', DEFAULT_PAKE_OPTIONS.icon) .option('-i, --icon <string>', 'application icon', DEFAULT_PAKE_OPTIONS.icon)
.option('-w, --width <number>', 'window width', validateNumberInput, DEFAULT_PAKE_OPTIONS.width) .option('-w, --width <number>', 'window width', validateNumberInput, DEFAULT_PAKE_OPTIONS.width)
.option('-h, --height <number>', 'window height', validateNumberInput, DEFAULT_PAKE_OPTIONS.height) .option('-h, --height <number>', 'window height', validateNumberInput, DEFAULT_PAKE_OPTIONS.height)
.option('-f, --fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen) .option('-f, --fullscreen', 'start in full screen mode', DEFAULT_PAKE_OPTIONS.fullscreen)
.option('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent) .option('-t, --transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent)
.option('-r, --no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable) .option('-r, --no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable)
.option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug) .option('-d, --debug', 'debug', DEFAULT_PAKE_OPTIONS.debug)
.option('-m, --multi-arch', "Supports both Intel and m1 chips, only for Mac.", DEFAULT_PAKE_OPTIONS.multiArch) .option('-m, --multi-arch', "available for Mac only, and supports both Intel and M1", DEFAULT_PAKE_OPTIONS.multiArch)
.action(async (url: string, options: PakeCliOptions) => { .action(async (url: string, options: PakeCliOptions) => {
await checkUpdateTips(); await checkUpdateTips();

2
bin/helpers/rust.ts vendored
View File

@@ -13,7 +13,7 @@ export async function installRust() {
await shellExec(IS_WIN ? RustInstallScriptForWin : RustInstallScriptFocMac); await shellExec(IS_WIN ? RustInstallScriptForWin : RustInstallScriptFocMac);
spinner.succeed(); spinner.succeed();
} catch (error) { } catch (error) {
console.error('install rust return code', error.message); console.error('Error codes that occur during the Rust installation process.', error.message);
spinner.fail(); spinner.fail();
process.exit(1); process.exit(1);

2
bin/options/icon.ts vendored
View File

@@ -22,7 +22,7 @@ export async function handleIcon(options: PakeAppOptions, url: string) {
} }
export async function getDefaultIcon() { export async function getDefaultIcon() {
logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)') logger.info('You haven\'t provided an app icon, so the default icon will be used. To assign a custom icon, please use the --icon option.')
let iconPath = 'src-tauri/icons/icon.icns'; let iconPath = 'src-tauri/icons/icon.icns';
if (IS_WIN) { if (IS_WIN) {
iconPath = 'src-tauri/png/icon_256.ico'; iconPath = 'src-tauri/png/icon_256.ico';

View File

@@ -11,7 +11,7 @@ export default async function handleOptions(options: PakeCliOptions, url: string
}; };
if (!appOptions.name) { if (!appOptions.name) {
appOptions.name = await promptText('please input your application name', getDomain(url)); appOptions.name = await promptText('Please enter the name of your application.', getDomain(url));
} }
appOptions.identifier = getIdentifier(appOptions.name, url); appOptions.identifier = getIdentifier(appOptions.name, url);

2
bin/utils/url.ts vendored
View File

@@ -42,6 +42,6 @@ export function normalizeUrl(urlToNormalize: string): string {
if (isurl(urlWithProtocol)) { if (isurl(urlWithProtocol)) {
return urlWithProtocol; return urlWithProtocol;
} else { } else {
throw new Error(`Your url "${urlWithProtocol}" is invalid`); throw new Error(`The URL "${urlWithProtocol}" you provided is invalid.`);
} }
} }

View File

@@ -4,7 +4,7 @@ import { normalizeUrl } from './url.js';
export function validateNumberInput(value: string) { export function validateNumberInput(value: string) {
const parsedValue = Number(value); const parsedValue = Number(value);
if (isNaN(parsedValue)) { if (isNaN(parsedValue)) {
throw new Commander.InvalidArgumentError('Not a number.'); throw new Commander.InvalidArgumentError('The input cannot be a number.');
} }
return parsedValue; return parsedValue;
} }