Skip to content

Commit c152143

Browse files
committed
📚 docs(docs): 更新 API 使用文档
1 parent 24156f3 commit c152143

File tree

1 file changed

+88
-10
lines changed

1 file changed

+88
-10
lines changed

README.md

Lines changed: 88 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,94 @@ import { setGitUserName, setGitUserEmail, checkGitUserInfo } from "code-genius";
248248
})();
249249
```
250250

251-
## 命令
252-
253-
| 命令 | 参数 | 默认值 | 功能描述 |
254-
| ---------- | ------------------------------------------------------------------- | ------- | --------------------------------------------- |
255-
| fix | --pattern \<pattern\> | './src' | 运行 eslint 静态扫描和修复代码中存在的问题 |
256-
| format | --pattern \<pattern\> | './src' | 运行 prettier 格式化代码风格 |
257-
| create | -- | -- | 运行 npm create 快速创建基础项目 |
258-
| template | -n, --project-name \<project-name\>, -f, --framework \<framework\>, | -- | 快速创建 CodeGenius 基础项目 |
259-
| lighthouse | --url \<url\> | -- | 运行 lighthouse 分析及收集 Web 应用的性能指标 |
260-
| quantity | -p, --path <path> | -- | 运行 cloc 分析并统计代码量 |
251+
## template 命令
252+
253+
快速创建 CodeGenius 基础项目
254+
基于 **CodeGenius** 内置模板快速创建新项目, 仅支持询问模式;
255+
256+
### 询问模式
257+
258+
```bash
259+
# 启动询问模式(默认)
260+
codeg template
261+
```
262+
263+
```
264+
# 询问过程
265+
1. 请输入项目名称
266+
2. 请输入 package name
267+
3. 请选择下列的有效模板
268+
4. 请选择下列的有效变体
269+
```
270+
271+
```bash
272+
# 启动询问模式(带参)
273+
codeg template -n project-salkdyfT -f vue
274+
```
275+
276+
| 选项 | 描述 |
277+
| ----------------------------------- | -------- |
278+
| -n, --project-name \<project-name\> | 项目名称 |
279+
| -f, --framework \<framework\> | 项目框架 |
280+
281+
```
282+
# 询问过程
283+
1. 请输入项目名称 (-n 输入则仅需确认)
284+
2. 请输入 package name
285+
3. 请选择下列的有效模板 (-f 输入有效则跳过)
286+
4. 请选择下列的有效变体
287+
```
288+
289+
## fix 命令
290+
291+
运行 `eslint` 静态扫描和修复代码中存在的问题, 仅支持命令模式;
292+
293+
### 命令模式
294+
295+
```bash
296+
# 检测和修改 src 文件夹中的代码
297+
codeg fix
298+
```
299+
300+
```bash
301+
# 检测和修改 src 和 components 文件夹中的代码
302+
codeg fix -p ./src -p ./components
303+
```
304+
305+
| 选项 | 描述 |
306+
| ------------------------- | ------------ |
307+
| -p, --pattern \<pattern\> | 设置匹配规则 |
308+
309+
PS: 依赖 `eslint` CLI 模式, 同时对项目配置的 `.eslintignore``.eslintrc.json` 生效.
310+
311+
## format 命令
312+
313+
运行 `prettier` 格式化代码风格, 仅支持命令模式;
314+
315+
### 命令模式
316+
317+
```bash
318+
# 格式化 src 文件夹下的文件
319+
codeg format
320+
```
321+
322+
```bash
323+
# 格式化 src 和 components 文件夹下的文件
324+
codeg format -p ./src -p ./components
325+
```
326+
| 选项 | 描述 |
327+
| ------------------------- | ------------ |
328+
| -p, --pattern \<pattern\> | 设置匹配规则 |
329+
330+
PS: 依赖 `prettier` CLI 模式, 同时对项目配置的 `.prettierignore``.prettierrc.json` 生效.
331+
332+
## 其他命令
333+
334+
| 命令 | 参数 | 默认值 | 功能描述 |
335+
| ---------- | ----------------- | ------ | --------------------------------------------- |
336+
| create | -- | -- | 运行 npm create 快速创建基础项目 |
337+
| lighthouse | --url \<url\> | -- | 运行 lighthouse 分析及收集 Web 应用的性能指标 |
338+
| quantity | -p, --path <path> | -- | 运行 cloc 分析并统计代码量 |
261339

262340
## 执照
263341

0 commit comments

Comments
 (0)