Skip to content

Commit a726c7b

Browse files
committed
feat(docs): 创建项目文档网站- 新增 Vitepress 配置文件和文档页面
- 添加项目介绍、特性说明和快速上手指南 - 设计并实现项目封面页面 - 更新 README 文件中的文档链接
1 parent 7820ce7 commit a726c7b

File tree

11 files changed

+448
-27
lines changed

11 files changed

+448
-27
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<div align="center">
22
<p>
3-
<a href="README.zh.md">中文</a> |
4-
<a href="README.md">English</a>
3+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.zh.md">中文</a> |
4+
<a href="/">English</a>
55
</p>
66

77
<h1>🐣inquirer_console</h1>
88
<p>An elegant interactive command line interface tool library</p>
99

1010
<p>
11-
<a href="#-installation"><strong>Installation</strong></a> •
12-
<a href="#-features"><strong>Features</strong></a> •
13-
<a href="#-usage-examples"><strong>Usage Examples</strong></a> •
14-
<a href="#-api-documentation"><strong>API Docs</strong></a> •
15-
<a href="#-contributing"><strong>Contributing</strong></a>
11+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.md#-installation"><strong>Installation</strong></a> •
12+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.md#-features"><strong>Features</strong></a> •
13+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.md#-usage-examples"><strong>Usage Examples</strong></a> •
14+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.md#-api-documentation"><strong>API Docs</strong></a> •
15+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.md#-contributing"><strong>Contributing</strong></a>
1616
</p>
1717

1818
<p>
@@ -122,7 +122,7 @@ description = Text(
122122
```python
123123
from inquirer_console import inquirer
124124

125-
# Define a list of questions
125+
# Define a select of questions
126126
questions = [
127127
{
128128
'type': 'input',
@@ -137,7 +137,7 @@ questions = [
137137
'default': True
138138
},
139139
{
140-
'type': 'list',
140+
'type': 'select',
141141
'name': 'favorite_lang',
142142
'message': 'What is your favorite programming language',
143143
'choices': [
@@ -328,7 +328,7 @@ pytest
328328

329329
## 📄 License
330330

331-
This project is licensed under the [MIT License](LICENSE).
331+
This project is licensed under the [MIT License](https://github.com/Eusen/inquirer_console/blob/master/LICENSE).
332332

333333
## 💖 Support the Project
334334

README.zh.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<div align="center">
22
<p>
3-
<a href="README.zh.md">中文</a> |
4-
<a href="README.md">English</a>
3+
<a href="/">中文</a> |
4+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.md">English</a>
55
</p>
66

77
<h1>🐣inquirer_console</h1>
88
<p>优雅的交互式命令行界面工具库</p>
99

1010
<p>
11-
<a href="#-安装"><strong>安装指南</strong></a> •
12-
<a href="#-特性"><strong>特性</strong></a> •
13-
<a href="#-使用示例"><strong>使用示例</strong></a> •
14-
<a href="#-api文档"><strong>API文档</strong></a> •
15-
<a href="#-贡献指南"><strong>贡献指南</strong></a>
11+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.zh.md#-安装"><strong>安装指南</strong></a> •
12+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.zh.md#-特性"><strong>特性</strong></a> •
13+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.zh.md#-使用示例"><strong>使用示例</strong></a> •
14+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.zh.md#-api文档"><strong>API文档</strong></a> •
15+
<a href="https://github.com/Eusen/inquirer_console/blob/master/README.zh.md#-贡献指南"><strong>贡献指南</strong></a>
1616
</p>
1717

1818
<p>
@@ -137,7 +137,7 @@ questions = [
137137
'default': True
138138
},
139139
{
140-
'type': 'list',
140+
'type': 'select',
141141
'name': 'favorite_lang',
142142
'message': '你最喜欢的编程语言是',
143143
'choices': [
@@ -328,7 +328,7 @@ pytest
328328

329329
## 📄 许可证
330330

331-
本项目采用 [MIT 许可证](LICENSE) 进行许可。
331+
本项目采用 [MIT 许可证](https://github.com/Eusen/inquirer_console/blob/master/LICENSE) 进行许可。
332332

333333
## 💖 支持项目
334334

changelog/v1.0.5.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ answers = inquirer.prompt([
3636
'message': 'What is your name?'
3737
},
3838
{
39-
'type': 'list',
39+
'type': 'select',
4040
'name': 'favorite_lang',
4141
'message': 'What is your favorite programming language?',
4242
'choices': ['Python', 'JavaScript', 'Rust']

changelog/v1.0.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ answers = inquirer.prompt([
3636
'message': '你的名字是什么?'
3737
},
3838
{
39-
'type': 'list',
39+
'type': 'select',
4040
'name': 'favorite_lang',
4141
'message': '你最喜欢的编程语言是?',
4242
'choices': ['Python', 'JavaScript', 'Rust']

docs/.vitepress/config.mts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
export default defineConfig({
4+
title: "inquirer_console",
5+
description: "优雅的交互式命令行界面工具库",
6+
lang: 'zh-CN',
7+
themeConfig: {
8+
nav: [
9+
{ text: '首页', link: '/' },
10+
{ text: '文章', link: '/articles/inquirer_console_intro' },
11+
{ text: 'GitHub', link: 'https://github.com/Eusen/inquirer_console' }
12+
],
13+
sidebar: {
14+
'/articles/': [
15+
{
16+
text: '文章',
17+
items: [
18+
{ text: '重磅!Python界最强命令行交互库诞生', link: '/articles/inquirer_console_intro' }
19+
]
20+
}
21+
]
22+
},
23+
socialLinks: [
24+
{ icon: 'github', link: 'https://github.com/Eusen/inquirer_console' }
25+
],
26+
footer: {
27+
message: '基于 MIT 许可发布',
28+
copyright: 'Copyright © 2024-present Eusen'
29+
}
30+
}
31+
})
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# 重磅!Python界最强命令行交互库诞生,让命令行也能优雅如诗!
2+
3+
> 本文首发于「Python技术」公众号,作者:Eusen
4+
5+
## 🎯 开篇
6+
7+
还记得那些年,我们写命令行程序时的痛苦吗?
8+
9+
```python
10+
print("请输入你的名字:")
11+
name = input()
12+
print("请输入你的年龄:")
13+
age = input()
14+
print("请输入你的性别:")
15+
gender = input()
16+
```
17+
18+
枯燥、单调、毫无美感可言。今天,我要给大家介绍一个革命性的Python库 —— `inquirer_console`,它将彻底改变你对命令行程序的认知!
19+
20+
## 🌟 为什么选择 inquirer_console?
21+
22+
想象一下,当你运行一个命令行程序时,看到的是这样的界面:
23+
24+
```
25+
> 请选择你的编程语言偏好:
26+
❯ Python
27+
JavaScript
28+
Rust
29+
Go
30+
```
31+
32+
或者这样的:
33+
34+
```
35+
> 选择你擅长的技术栈:
36+
❯ [X] Python
37+
[ ] JavaScript
38+
[X] Rust
39+
[ ] Go
40+
```
41+
42+
优雅的交互体验,流畅的键盘操作,完美的视觉反馈。这就是 `inquirer_console` 带给我们的改变!
43+
44+
## 💫 核心特性
45+
46+
### 1. 零依赖,纯原生实现
47+
- 完全基于Python标准库开发
48+
- 无需安装任何额外依赖
49+
- 轻量级,高性能
50+
51+
### 2. 跨平台完美支持
52+
- Windows
53+
- macOS
54+
- Linux/Unix
55+
- 所有主流终端模拟器
56+
57+
### 3. 丰富的交互类型
58+
- 文本输入(Input)
59+
- 确认提示(Confirm)
60+
- 单选列表(Select)
61+
- 多选列表(Checkbox)
62+
- 密码输入(Password)
63+
- 多行文本(Text)
64+
65+
### 4. 强大的扩展性
66+
- 自定义验证规则
67+
- 实时数据过滤
68+
- 灵活的默认值设置
69+
- 优雅的中断处理
70+
71+
## 🚀 快速上手
72+
73+
```python
74+
from inquirer_console import inquirer
75+
76+
answers = inquirer.prompt([
77+
{
78+
'type': 'input',
79+
'name': 'name',
80+
'message': '你的名字是',
81+
'validate': lambda val: True if val else "名字不能为空!"
82+
},
83+
{
84+
'type': 'select',
85+
'name': 'favorite_lang',
86+
'message': '你最喜欢的编程语言是',
87+
'choices': [
88+
{'name': 'Python', 'value': 'python'},
89+
{'name': 'JavaScript', 'value': 'js'},
90+
{'name': 'Rust', 'value': 'rust'}
91+
]
92+
}
93+
])
94+
95+
print(f"你好, {answers['name']}!")
96+
print(f"你最喜欢的语言是: {answers['favorite_lang']}")
97+
```
98+
99+
## 💡 高级玩法
100+
101+
### 1. 自定义验证
102+
```python
103+
def validate_age(val):
104+
try:
105+
age = int(val)
106+
if age <= 0:
107+
return "年龄必须是正整数!"
108+
elif age > 120:
109+
return "年龄不能超过120岁!"
110+
return True
111+
except ValueError:
112+
return "请输入有效的数字!"
113+
114+
age = Input(
115+
message="你的年龄是",
116+
validate=validate_age
117+
).prompt()
118+
```
119+
120+
### 2. 优雅的中断处理
121+
```python
122+
try:
123+
answers = inquirer.prompt([...])
124+
except ExitPromptError:
125+
print("\n用户取消了操作,正在优雅退出...")
126+
```
127+
128+
## 🎨 设计理念
129+
130+
`inquirer_console` 的设计理念是:**让命令行交互优雅如诗**
131+
132+
- 遵循"最小惊讶原则"
133+
- 保持API的简洁性
134+
- 提供流畅的用户体验
135+
- 确保代码的可维护性
136+
137+
## 🌈 未来展望
138+
139+
我们计划在未来版本中添加更多激动人心的特性:
140+
141+
- 自定义主题支持
142+
- 更丰富的动画效果
143+
- 更强大的验证系统
144+
- 更多的交互类型
145+
146+
## 🎁 如何参与
147+
148+
如果你对这个项目感兴趣,欢迎:
149+
150+
- ⭐ 在GitHub上给我们点星
151+
- 🐛 提交issue或PR
152+
- 📝 完善文档
153+
- 📣 在社交媒体上分享
154+
155+
## 💪 结语
156+
157+
在这个AI时代,命令行程序依然扮演着重要角色。`inquirer_console` 的出现,让命令行程序也能拥有优雅的用户体验。
158+
159+
让我们一起,用代码创造更美好的世界!
160+
161+
---
162+
163+
> 如果你觉得这篇文章对你有帮助,欢迎点赞、转发、关注!
164+
>
165+
> 更多精彩内容,尽在「Python技术」公众号!
166+
167+
#Python #命令行 #开源项目 #技术分享

0 commit comments

Comments
 (0)