{"id":19751153,"url":"https://github.com/mipengine/mip-cli-plugin-foo","last_synced_at":"2026-06-14T05:32:12.390Z","repository":{"id":76005212,"uuid":"138564744","full_name":"mipengine/mip-cli-plugin-foo","owner":"mipengine","description":"mip2.0 CLI plugin 开发模板","archived":false,"fork":false,"pushed_at":"2018-06-25T09:07:34.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-28T08:32:39.722Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mipengine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-25T08:21:48.000Z","updated_at":"2018-06-25T09:07:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"5d9eadd8-d87f-4e47-b87d-7441a1ff3c7c","html_url":"https://github.com/mipengine/mip-cli-plugin-foo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mipengine/mip-cli-plugin-foo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-foo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-foo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-foo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-foo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mipengine","download_url":"https://codeload.github.com/mipengine/mip-cli-plugin-foo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-foo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34310801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T02:42:39.535Z","updated_at":"2026-06-14T05:32:12.374Z","avatar_url":"https://github.com/mipengine.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mip-cli-plugin-foo\n\n## mip2 cli 用户自定义命令插件 开发示例\n\n[开始扩展自定义命令](https://github.com/mipengine/mip2/blob/master/docs/cli/cli-user-plugin.md)\n\n项目结构如下：\n\n```\n├── cli\n│   ├── foo\n│   │   └── bar.js    // 对应子命令，mip2 foo bar\n│   └── foo.js        // 对应主命令，mip2 foo\n├── index.js          // 模块入口\n├── lib               // 建议把业务逻辑写在 lib 目录\n├── package.json\n└── README.md\n```\n\n`cli` 目录是命令的入口，所有的命令都应该放在这里。\n`mip2 foo` 会自动读取 `cli/foo.js` 对应的模块。同理：\n`mip2 foo bar` 会自动读取 `cli/foo/bar.js` 对应的模块。\n\n\u003e 注意：模块名称与命令名称必须保持一致，否则会找不到对应的模块\n\n### 配置扩展命令\n\n自定义扩展命令可以通过命令模块中的 `cli.config` 进行配置：\n\n``` javascript\n  config: {\n    // 命令描述信息，显示在命令列表说明中\n    description: 'foo bar 功能测试',\n\n    // 和 usage 一起组成 Usage 信息\n    name: 'mip2 foo',\n\n    // \u003cid\u003e 表示 id 为必选参数，[id] 表示 Id 为可选参数\n    usage: '\u003cid\u003e',\n\n    // 命令 options\n    options: [\n      ['-f, --force', '强制执行'],\n      ['-p, --port \u003cvalue\u003e', '端口号']\n    ],\n\n    // 帮助信息， --help 时显示\n    help: [\n      '',\n      '  Examples:',\n      '    # 测试自定义 plugin 命令',\n      '    $ mip2 foo \u003cid\u003e -f',\n      '    # 测试自定义 plugin 命令',\n      '    $ mip2 foo \u003cid\u003e -p 8888'\n    ].join('\\n')\n  },\n```\n\n### 扩展命令入口\n\n`cli.main` 是命令执行的入口\n\n``` javascript\n  /**\n   * 命令执行入口\n   *\n   * @param {Array} 命令接收的参数数组\n   * @param {Object} 命令配置的 options 对象。option 接收 \u003cvalue\u003e 时获取值，否则返回 boolean 类型\n   */\n  main: function (args, opts) {\n    // your own stuff\n    console.log('args: ')\n    console.log(args)\n    console.log('opts: ')\n    console.log('opts.force: ' + opts.force)\n    console.log('opts.port: ' + opts.port)\n  }\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmipengine%2Fmip-cli-plugin-foo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmipengine%2Fmip-cli-plugin-foo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmipengine%2Fmip-cli-plugin-foo/lists"}