#!/usr/bin/env node
import{Command}from'commander'// ...
// define commands
program.command('create <project-name>').description('create a new FixIt project from a template').action(createAction)program.command('check').description('check the latest version of FixIt theme').action(checkAction)program.command('help <command>').description('display help for a specific command').action(helpAction)// define cli
program.usage('<command> [options]').description(description).version(`${pkg.name} v${pkg.version}`,'-v, --version').showHelpAfterError().parse(process.argv)
然后再去实现这些命令所执行的动作:createAction、checkAction、helpAction 和完善一下 logo 和 description 等细节。
Usage: fixit <command> [options]
=============================================
▄████ ▄█ ▄ ▄█ ▄▄▄▄▀
█▀ ▀ ██ ▀▄ █ ██ ▀▀▀ █
█▀▀ ██ █ ▀ ██ █
█ ▐█ ▄ █ ▐█ █
█ ▐ █ ▀▄ ▐ ▀
▀ ▀
fixit-cli v1.0.2
A cli tool for FixIt theme.
=============================================
FixIt is a clean, elegant but advanced blog theme for Hugo
built with love by Lruihao and his friends.
Complete documentation is available at https://fixit.lruihao.cn/.
Options:
-v, --version output the version number
-h, --help display help for command
Commands:
create <project-name> create a new FixIt project from a template
check check the latest version of FixIt theme
help <command> display help for a specific command