ITPub博客

首页 > 应用开发 > IT综合 > 前端技术之:迪士尼网站平台搭建命令模块及其执行方法

前端技术之:迪士尼网站平台搭建命令模块及其执行方法

IT综合 作者:在看眼里 时间:2019-11-05 14:51:49 0 删除 编辑

一、创建一个命令模块
1、package.json
迪士尼网站平台搭建q<277.03.4.83.6>

{
  "name": "@uad/nat-cli",
  "version": "0.0.2",
  "description": "Demo",
  "main": "index.js",
  "bin": {
    "artisan": "./src/artisan.js"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git"
  },
  "keywords": [
    "CLI"
  ],
  "author": "chunrong.liu",
  "license": "ISC",
  "dependencies": {
    "shelljs": "^0.8.3",
    "yargs": "^13.2.4"
  }
}

2、src/artisan.js

#!/usr/bin/env node
require('shelljs/global');
var argv = require('yargs')
.option('n', {
alias : 'name',
demand: true,
default: 'tom',
describe: 'your name',
type: 'string'
})
.usage('Usage: hello [options]')
.example('hello -n tom', 'say hello to Tom')
.help('h')
.alias('h', 'help')
.epilog('Copyright 2019')
.command("morning", "good morning", function (yargs) {
echo("Good Morning");
var argv = yargs.reset()
.option("m", {
alias: "message",
description: "provide any sentence"
})
.help("h")
.alias("h", "help")
.argv;
echo(argv.m);
})
.argv;
console.log('hello ', argv.n);
console.log(argv._);

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69952857/viewspace-2662706/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2019-11-05

  • 博文量
    1
  • 访问量
    504