leanup 0.0.3__tar.gz → 0.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
leanup-0.0.4/PKG-INFO ADDED
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: leanup
3
+ Version: 0.0.4
4
+ Summary: Python package for Lean Environment Management
5
+ Author-email: Lean-zh Community <leanprover@outlook.com>
6
+ Maintainer-email: Lean-zh Community <leanprover@outlook.com>
7
+ License: MIT license
8
+ Project-URL: bugs, https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues
9
+ Project-URL: changelog, https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/blob/master/changelog.md
10
+ Project-URL: homepage, https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: gitpython
14
+ Requires-Dist: psutil
15
+ Requires-Dist: click
16
+ Requires-Dist: platformdirs
17
+ Requires-Dist: loguru
18
+ Requires-Dist: requests
19
+ Requires-Dist: toml
20
+ Provides-Extra: dev
21
+ Requires-Dist: coverage; extra == "dev"
22
+ Requires-Dist: mypy; extra == "dev"
23
+ Requires-Dist: pytest; extra == "dev"
24
+ Requires-Dist: ruff; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # LeanUp
28
+
29
+ <div align="center">
30
+ <a href="https://pypi.python.org/pypi/leanup">
31
+ <img src="https://img.shields.io/pypi/v/leanup.svg" alt="PyPI version" />
32
+ </a>
33
+ <a href="https://github.com/Lean-zh/LeanUp/actions/workflows/ci.yaml">
34
+ <img src="https://github.com/Lean-zh/LeanUp/actions/workflows/ci.yaml/badge.svg" alt="Tests" />
35
+ </a>
36
+ <a href="https://codecov.io/gh/Lean-zh/LeanUp">
37
+ <img src="https://codecov.io/gh/Lean-zh/LeanUp/branch/main/graph/badge.svg" alt="Coverage" />
38
+ </a>
39
+ </div>
40
+
41
+ <div align="center">
42
+
43
+ **一个用于管理 Lean 数学证明语言环境的 Python 工具**
44
+
45
+ [English](README-en.md) | [简体中文](README.md)
46
+
47
+ </div>
48
+
49
+ ## 🎯 功能特性
50
+
51
+ - **🔧 elan 管理**: 一键安装和管理 Lean 工具链管理器 elan
52
+ - **🌍 跨平台支持**: 支持 Linux、macOS 和 Windows
53
+ - **📦 简单易用**: 通过 `pip install -e /path/to/LeanUp` 快速安装
54
+ - **🔄 命令代理**: 透明代理所有 elan 命令,无缝体验
55
+ - **📊 状态监控**: 实时查看 Lean 环境状态和已安装工具链
56
+
57
+ ## 🚀 快速开始
58
+
59
+ ### 安装
60
+
61
+ ```bash
62
+ # 从源码安装
63
+ pip install -e /path/to/LeanUp
64
+
65
+ # 或者克隆仓库后安装
66
+ git clone https://github.com/Lean-zh/LeanUp.git
67
+ cd LeanUp
68
+ pip install -e .
69
+ ```
70
+
71
+ ### 基础使用
72
+
73
+ ```bash
74
+ # 查看帮助
75
+ leanup --help
76
+
77
+ # 初始化 Lean 环境(安装 elan 工具链管理器)
78
+ leanup init
79
+
80
+ # 查看状态
81
+ leanup status
82
+
83
+ # 代理执行 elan 命令
84
+ leanup elan --help
85
+ leanup elan toolchain list
86
+ leanup elan toolchain install stable
87
+ leanup elan default stable
88
+ ```
89
+
90
+ ## 📖 详细使用指南
91
+
92
+ ### 初始化环境
93
+
94
+ ```bash
95
+ # 初始化环境并安装最新版本的 elan
96
+ leanup init
97
+
98
+ # 强制重新初始化
99
+ leanup init --force
100
+
101
+ # 初始化但不修改 shell 配置文件
102
+ leanup init --no-modify-path
103
+ ```
104
+
105
+ ### 管理 Lean 工具链
106
+
107
+ 初始化环境后,您可以使用 `leanup elan` 命令来管理 Lean 工具链:
108
+
109
+ ```bash
110
+ # 列出所有可用的工具链
111
+ leanup elan toolchain list
112
+
113
+ # 安装稳定版工具链
114
+ leanup elan toolchain install stable
115
+
116
+ # 安装夜间构建版本
117
+ leanup elan toolchain install leanprover/lean4:nightly
118
+
119
+ # 设置默认工具链
120
+ leanup elan default stable
121
+
122
+ # 更新所有工具链
123
+ leanup elan update
124
+
125
+ # 查看当前活动的工具链
126
+ leanup elan show
127
+ ```
128
+
129
+ ### 项目管理
130
+
131
+ ```bash
132
+ # 为项目设置特定的工具链
133
+ cd your-lean-project
134
+ leanup elan override set stable
135
+
136
+ # 移除项目的工具链覆盖
137
+ leanup elan override unset
138
+ ```
139
+
140
+ ## 🛠️ 开发
141
+
142
+ ### 环境设置
143
+
144
+ ```bash
145
+ # 克隆仓库
146
+ git clone https://github.com/Lean-zh/LeanUp.git
147
+ cd LeanUp
148
+
149
+ # 安装开发依赖
150
+ pip install -r requirements_dev.txt
151
+
152
+ # 安装项目(可编辑模式)
153
+ pip install -e .
154
+ ```
155
+
156
+ ### 运行测试
157
+
158
+ ```bash
159
+ # 运行所有测试
160
+ pytest tests/ -v
161
+
162
+ # 运行测试并生成覆盖率报告
163
+ coverage run -m pytest tests/
164
+ coverage report -m
165
+ ```
166
+
167
+ ### 代码质量检查
168
+
169
+ ```bash
170
+ # 代码风格检查
171
+ ruff check .
172
+
173
+ # 类型检查
174
+ mypy .
175
+ ```
176
+
177
+ ## 🌍 跨平台支持
178
+
179
+ LeanUp 在以下平台上经过测试:
180
+
181
+ - **Linux**: Ubuntu 20.04+, CentOS 7+, Debian 10+
182
+ - **macOS**: macOS 10.15+(Intel 和 Apple Silicon)
183
+ - **Windows**: Windows 10+
184
+
185
+ ## 📊 项目状态
186
+
187
+ | 功能 | 状态 | 说明 |
188
+ |------|------|------|
189
+ | elan 安装 | ✅ | 支持自动检测平台和版本 |
190
+ | 命令代理 | ✅ | 透明传递所有 elan 命令 |
191
+ | 跨平台支持 | ✅ | Linux/macOS/Windows |
192
+ | 单元测试 | ✅ | 覆盖率 > 85% |
193
+ | CI/CD | ✅ | GitHub Actions 多平台测试 |
194
+
195
+ ## 🤝 贡献
196
+
197
+ 欢迎贡献代码!请查看 [贡献指南](CONTRIBUTING.md) 了解详细信息。
198
+
199
+ ## 📝 许可证
200
+
201
+ 本项目采用 MIT 许可证。详细信息请查看 [LICENSE](LICENSE) 文件。
202
+
203
+ ## 🔗 相关链接
204
+
205
+ - [Lean 官方网站](https://leanprover.github.io/)
206
+ - [Lean 社区文档](https://leanprover-community.github.io/)
207
+ - [elan 工具链管理器](https://github.com/leanprover/elan)
leanup-0.0.4/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # LeanUp
2
+
3
+ <div align="center">
4
+ <a href="https://pypi.python.org/pypi/leanup">
5
+ <img src="https://img.shields.io/pypi/v/leanup.svg" alt="PyPI version" />
6
+ </a>
7
+ <a href="https://github.com/Lean-zh/LeanUp/actions/workflows/ci.yaml">
8
+ <img src="https://github.com/Lean-zh/LeanUp/actions/workflows/ci.yaml/badge.svg" alt="Tests" />
9
+ </a>
10
+ <a href="https://codecov.io/gh/Lean-zh/LeanUp">
11
+ <img src="https://codecov.io/gh/Lean-zh/LeanUp/branch/main/graph/badge.svg" alt="Coverage" />
12
+ </a>
13
+ </div>
14
+
15
+ <div align="center">
16
+
17
+ **一个用于管理 Lean 数学证明语言环境的 Python 工具**
18
+
19
+ [English](README-en.md) | [简体中文](README.md)
20
+
21
+ </div>
22
+
23
+ ## 🎯 功能特性
24
+
25
+ - **🔧 elan 管理**: 一键安装和管理 Lean 工具链管理器 elan
26
+ - **🌍 跨平台支持**: 支持 Linux、macOS 和 Windows
27
+ - **📦 简单易用**: 通过 `pip install -e /path/to/LeanUp` 快速安装
28
+ - **🔄 命令代理**: 透明代理所有 elan 命令,无缝体验
29
+ - **📊 状态监控**: 实时查看 Lean 环境状态和已安装工具链
30
+
31
+ ## 🚀 快速开始
32
+
33
+ ### 安装
34
+
35
+ ```bash
36
+ # 从源码安装
37
+ pip install -e /path/to/LeanUp
38
+
39
+ # 或者克隆仓库后安装
40
+ git clone https://github.com/Lean-zh/LeanUp.git
41
+ cd LeanUp
42
+ pip install -e .
43
+ ```
44
+
45
+ ### 基础使用
46
+
47
+ ```bash
48
+ # 查看帮助
49
+ leanup --help
50
+
51
+ # 初始化 Lean 环境(安装 elan 工具链管理器)
52
+ leanup init
53
+
54
+ # 查看状态
55
+ leanup status
56
+
57
+ # 代理执行 elan 命令
58
+ leanup elan --help
59
+ leanup elan toolchain list
60
+ leanup elan toolchain install stable
61
+ leanup elan default stable
62
+ ```
63
+
64
+ ## 📖 详细使用指南
65
+
66
+ ### 初始化环境
67
+
68
+ ```bash
69
+ # 初始化环境并安装最新版本的 elan
70
+ leanup init
71
+
72
+ # 强制重新初始化
73
+ leanup init --force
74
+
75
+ # 初始化但不修改 shell 配置文件
76
+ leanup init --no-modify-path
77
+ ```
78
+
79
+ ### 管理 Lean 工具链
80
+
81
+ 初始化环境后,您可以使用 `leanup elan` 命令来管理 Lean 工具链:
82
+
83
+ ```bash
84
+ # 列出所有可用的工具链
85
+ leanup elan toolchain list
86
+
87
+ # 安装稳定版工具链
88
+ leanup elan toolchain install stable
89
+
90
+ # 安装夜间构建版本
91
+ leanup elan toolchain install leanprover/lean4:nightly
92
+
93
+ # 设置默认工具链
94
+ leanup elan default stable
95
+
96
+ # 更新所有工具链
97
+ leanup elan update
98
+
99
+ # 查看当前活动的工具链
100
+ leanup elan show
101
+ ```
102
+
103
+ ### 项目管理
104
+
105
+ ```bash
106
+ # 为项目设置特定的工具链
107
+ cd your-lean-project
108
+ leanup elan override set stable
109
+
110
+ # 移除项目的工具链覆盖
111
+ leanup elan override unset
112
+ ```
113
+
114
+ ## 🛠️ 开发
115
+
116
+ ### 环境设置
117
+
118
+ ```bash
119
+ # 克隆仓库
120
+ git clone https://github.com/Lean-zh/LeanUp.git
121
+ cd LeanUp
122
+
123
+ # 安装开发依赖
124
+ pip install -r requirements_dev.txt
125
+
126
+ # 安装项目(可编辑模式)
127
+ pip install -e .
128
+ ```
129
+
130
+ ### 运行测试
131
+
132
+ ```bash
133
+ # 运行所有测试
134
+ pytest tests/ -v
135
+
136
+ # 运行测试并生成覆盖率报告
137
+ coverage run -m pytest tests/
138
+ coverage report -m
139
+ ```
140
+
141
+ ### 代码质量检查
142
+
143
+ ```bash
144
+ # 代码风格检查
145
+ ruff check .
146
+
147
+ # 类型检查
148
+ mypy .
149
+ ```
150
+
151
+ ## 🌍 跨平台支持
152
+
153
+ LeanUp 在以下平台上经过测试:
154
+
155
+ - **Linux**: Ubuntu 20.04+, CentOS 7+, Debian 10+
156
+ - **macOS**: macOS 10.15+(Intel 和 Apple Silicon)
157
+ - **Windows**: Windows 10+
158
+
159
+ ## 📊 项目状态
160
+
161
+ | 功能 | 状态 | 说明 |
162
+ |------|------|------|
163
+ | elan 安装 | ✅ | 支持自动检测平台和版本 |
164
+ | 命令代理 | ✅ | 透明传递所有 elan 命令 |
165
+ | 跨平台支持 | ✅ | Linux/macOS/Windows |
166
+ | 单元测试 | ✅ | 覆盖率 > 85% |
167
+ | CI/CD | ✅ | GitHub Actions 多平台测试 |
168
+
169
+ ## 🤝 贡献
170
+
171
+ 欢迎贡献代码!请查看 [贡献指南](CONTRIBUTING.md) 了解详细信息。
172
+
173
+ ## 📝 许可证
174
+
175
+ 本项目采用 MIT 许可证。详细信息请查看 [LICENSE](LICENSE) 文件。
176
+
177
+ ## 🔗 相关链接
178
+
179
+ - [Lean 官方网站](https://leanprover.github.io/)
180
+ - [Lean 社区文档](https://leanprover-community.github.io/)
181
+ - [elan 工具链管理器](https://github.com/leanprover/elan)
@@ -2,6 +2,10 @@
2
2
 
3
3
  __author__ = """Lean-zh Community"""
4
4
  __email__ = 'leanprover@outlook.com'
5
- __version__ = '0.0.3'
5
+ __version__ = '0.0.4'
6
6
 
7
+ # 导出主要类供外部使用
7
8
  from leanup.utils import CommandExecutor
9
+ from leanup.elan_manager import ElanManager
10
+
11
+ __all__ = ['CommandExecutor', 'ElanManager']
@@ -0,0 +1,276 @@
1
+ import click
2
+ import sys
3
+ import os
4
+ import toml
5
+ from pathlib import Path
6
+ from loguru import logger
7
+ from .elan_manager import ElanManager
8
+ from .const import OS_TYPE
9
+
10
+
11
+ # 配置 loguru
12
+ logger.remove()
13
+ logger.add(sys.stderr, level="INFO", format="<green>{time:HH:mm:ss}</green> | <level>{level: <8}</level> | <level>{message}</level>")
14
+
15
+
16
+ @click.group()
17
+ @click.option('--verbose', '-v', is_flag=True, help='Enable verbose output')
18
+ def main(verbose):
19
+ """LeanUp - Lean Environment Management Tool
20
+
21
+ A Python tool for managing Lean mathematical proof language environments.
22
+ """
23
+ if verbose:
24
+ logger.remove()
25
+ logger.add(sys.stderr, level="DEBUG", format="<green>{time:HH:mm:ss}</green> | <level>{level: <8}</level> | <level>{message}</level>")
26
+
27
+
28
+ @main.command()
29
+ @click.option('--force', '-f', is_flag=True, help='Force reinstall even if elan exists')
30
+ @click.option('--no-modify-path', is_flag=True, help='Do not modify shell config files')
31
+ def init(force, no_modify_path):
32
+ """Initialize Lean environment with elan toolchain manager
33
+
34
+ This command will:
35
+ 1. Install the latest stable version of elan
36
+ 2. Create .leanup directory for preferences
37
+ 3. Configure environment variables in shell config files
38
+
39
+ Examples:
40
+ leanup init # Initialize environment
41
+ leanup init --force # Force reinstall
42
+ leanup init --no-modify-path # Don't modify shell config files
43
+ """
44
+ manager = ElanManager()
45
+
46
+ click.echo(f"Initializing Lean environment for {OS_TYPE}...")
47
+
48
+ # 1. 安装最新稳定版 elan
49
+ success = manager.install_elan(force=force)
50
+
51
+ if not success:
52
+ click.echo("elan installation failed!")
53
+ sys.exit(1)
54
+
55
+ # 2. 创建 .leanup 目录和偏好设置文件
56
+ leanup_dir = Path.home() / '.leanup'
57
+ leanup_dir.mkdir(exist_ok=True)
58
+
59
+ # 创建偏好设置 toml 文件
60
+ config_path = leanup_dir / 'config.toml'
61
+ if not config_path.exists() or force:
62
+ config = {
63
+ 'elan': {
64
+ 'home': str(manager.elan_home),
65
+ 'default_toolchain': 'stable'
66
+ },
67
+ 'preferences': {
68
+ 'auto_update_check': True,
69
+ 'telemetry_enabled': False
70
+ }
71
+ }
72
+
73
+ with open(config_path, 'w') as f:
74
+ toml.dump(config, f)
75
+
76
+ click.echo(f"Created configuration file: {config_path}")
77
+
78
+ # 3. 配置环境变量(如果用户没有禁用)
79
+ if not no_modify_path and OS_TYPE != 'Windows':
80
+ modified = False
81
+
82
+ # 检查并更新 .bashrc
83
+ bashrc_path = Path.home() / '.bashrc'
84
+ if bashrc_path.exists():
85
+ modified |= _update_shell_config(bashrc_path, manager.elan_bin_dir)
86
+
87
+ # 检查并更新 .zshrc
88
+ zshrc_path = Path.home() / '.zshrc'
89
+ if zshrc_path.exists():
90
+ modified |= _update_shell_config(zshrc_path, manager.elan_bin_dir)
91
+
92
+ if modified:
93
+ click.echo("\nEnvironment variables configured in shell config files.")
94
+ click.echo("Please restart your terminal or run the following command to apply changes:")
95
+ click.echo(" source ~/.bashrc # or source ~/.zshrc")
96
+
97
+ # 显示安装信息
98
+ info = manager.get_status_info()
99
+ click.echo("\nelan installation successful!")
100
+ click.echo(f"Installation location: {info['executable']}")
101
+ click.echo(f"ELAN_HOME: {info['elan_home']}")
102
+ click.echo(f"Version: {info['version']}")
103
+
104
+ # 提示下一步操作
105
+ click.echo("\nYou can now use the following commands:")
106
+ click.echo(" leanup elan --help # Show elan help")
107
+ click.echo(" leanup status # Check status")
108
+ click.echo(" leanup elan toolchain install stable # Install stable toolchain")
109
+
110
+ @main.command()
111
+ @click.argument('toolchain', required=False)
112
+ @click.option('--force', '-f', is_flag=True, help='Force reinstall even if already installed')
113
+ @click.option('--no-default', is_flag=True, help='Do not set as default toolchain')
114
+ def install(toolchain, force, no_default):
115
+ """Install specific Lean toolchain
116
+
117
+ This command installs a specific Lean toolchain using elan.
118
+ If no toolchain is specified, it will install the stable version.
119
+
120
+ Examples:
121
+ leanup install # Install stable toolchain
122
+ leanup install leanprover/lean4:stable # Install specific toolchain
123
+ leanup install --no-default # Install without setting as default
124
+ """
125
+ manager = ElanManager()
126
+
127
+ # 检查 elan 是否已安装,如果未安装则自动安装
128
+ if not manager.is_elan_installed():
129
+ click.echo("elan 未安装,正在自动安装...")
130
+ success = manager.install_elan(force=force)
131
+ if not success:
132
+ click.echo("elan 安装失败!无法继续安装工具链。")
133
+ sys.exit(1)
134
+ click.echo("elan 安装成功!继续安装工具链...")
135
+
136
+ # 如果未指定工具链,默认使用 stable
137
+ if not toolchain:
138
+ toolchain = "stable"
139
+ click.echo(f"未指定工具链,将安装默认的 stable 版本")
140
+
141
+ # 检查是否有已安装的工具链
142
+ existing_toolchains = manager.get_installed_toolchains()
143
+ default_toolchain = manager.get_default_toolchain()
144
+
145
+ # 确定是否设置为默认工具链
146
+ set_as_default = False
147
+ if not no_default:
148
+ # 如果是首次安装工具链或强制安装,则设置为默认
149
+ if not existing_toolchains or force:
150
+ set_as_default = True
151
+ # 如果当前没有默认工具链,也设置为默认
152
+ elif not default_toolchain:
153
+ set_as_default = True
154
+
155
+ click.echo(f"正在安装工具链: {toolchain}")
156
+ success = manager.install_toolchain(toolchain, set_as_default)
157
+
158
+ if success:
159
+ if set_as_default:
160
+ click.echo(f"工具链 {toolchain} 安装成功并设置为默认工具链")
161
+ else:
162
+ click.echo(f"工具链 {toolchain} 安装成功")
163
+
164
+ # 显示当前状态
165
+ info = manager.get_status_info()
166
+ if info['toolchains']:
167
+ click.echo("\n已安装的工具链:")
168
+ for tc in info['toolchains']:
169
+ if default_toolchain and tc == default_toolchain:
170
+ click.echo(f" • {tc} (default)")
171
+ else:
172
+ click.echo(f" • {tc}")
173
+ else:
174
+ click.echo(f"工具链 {toolchain} 安装失败")
175
+ sys.exit(1)
176
+
177
+
178
+ @main.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True))
179
+ @click.pass_context
180
+ def elan(ctx):
181
+ """Proxy elan commands
182
+
183
+ Pass all arguments directly to the elan tool. This allows you to use leanup elan just like native elan.
184
+
185
+ Examples:
186
+ leanup elan --help # Show elan help
187
+ leanup elan toolchain list # List installed toolchains
188
+ leanup elan toolchain install stable # Install stable toolchain
189
+ leanup elan default stable # Set default toolchain
190
+ leanup elan update # Update toolchains
191
+ """
192
+ manager = ElanManager()
193
+
194
+ # 传递所有额外参数给 elan
195
+ exit_code = manager.proxy_elan_command(ctx.args)
196
+ sys.exit(exit_code)
197
+
198
+
199
+ @main.command()
200
+ def status():
201
+ """Show LeanUp and elan status information"""
202
+ manager = ElanManager()
203
+ info = manager.get_status_info()
204
+
205
+ click.echo("LeanUp Status Information")
206
+ click.echo("=" * 50)
207
+
208
+ click.echo(f"Operating System: {OS_TYPE}")
209
+
210
+ # 检查 .leanup 目录
211
+ leanup_dir = Path.home() / '.leanup'
212
+ if leanup_dir.exists():
213
+ click.echo(f"LeanUp Config: {leanup_dir / 'config.toml'}")
214
+ else:
215
+ click.echo("LeanUp Config: Not initialized (run 'leanup init')")
216
+
217
+ if info['installed']:
218
+ click.echo("elan Status: Installed")
219
+ click.echo(f"Version: {info['version']}")
220
+ click.echo(f"Executable: {info['executable']}")
221
+ click.echo(f"ELAN_HOME: {info['elan_home']}")
222
+
223
+ toolchains = info['toolchains']
224
+ if toolchains:
225
+ click.echo(f"Installed Toolchains ({len(toolchains)}):")
226
+ for toolchain in toolchains:
227
+ click.echo(f" • {toolchain}")
228
+ else:
229
+ click.echo("Installed Toolchains: None")
230
+ click.echo("Tip: Run 'leanup elan toolchain install stable' to install stable toolchain")
231
+ else:
232
+ click.echo("elan Status: Not Installed")
233
+ click.echo("Tip: Run 'leanup init' to initialize the environment")
234
+
235
+
236
+ @main.command()
237
+ def version():
238
+ """Show LeanUp version information"""
239
+ from . import __version__
240
+ click.echo(f"LeanUp Version: {__version__}")
241
+
242
+
243
+ # 保留原有的 repo 组以保持向后兼容
244
+ @main.group()
245
+ def repo():
246
+ """Manage Lean repository installations (experimental feature)"""
247
+ pass
248
+
249
+
250
+ def _update_shell_config(config_path, bin_dir):
251
+ """更新 shell 配置文件,添加 elan bin 目录到 PATH
252
+
253
+ Args:
254
+ config_path: shell 配置文件路径
255
+ bin_dir: elan bin 目录路径
256
+
257
+ Returns:
258
+ bool: 是否修改了配置文件
259
+ """
260
+ with open(config_path, 'r') as f:
261
+ content = f.read()
262
+
263
+ # 检查是否已经配置了 PATH
264
+ path_str = f'export PATH="{bin_dir}:$PATH"'
265
+ if path_str in content:
266
+ return False
267
+
268
+ # 添加到文件末尾
269
+ with open(config_path, 'a') as f:
270
+ f.write(f"\n# Added by LeanUp\n{path_str}\n")
271
+
272
+ return True
273
+
274
+
275
+ if __name__ == '__main__':
276
+ main()