add the readme.md file

This commit is contained in:
2025-07-27 20:25:54 +08:00
parent a44747e4c1
commit 0519ff6739
2 changed files with 286 additions and 0 deletions

View File

@ -2671,3 +2671,177 @@ curl -sL https://git.zyj.best/theshy/gitea-downloader/raw/branch/main/install.sh
---
_**User**_
为整个项目写一个详细的readme文件
---
_**Assistant**_
<think><details><summary>Thought Process</summary>
**Composing a README**
I'm currently drafting the README.md for the project. I've decided on the project title, which is “Gitea Interactive Downloader”. My next step involves outlining the rest of the document, starting with sections for installation, usage, and contributing guidelines.
**Planning the Structure**
I've finalized the structure of the README.md file, which will follow a logical flow. I've laid out sections for the project title, badges, introduction, features, prerequisites, and installation instructions. The "Usage" section is next on my list, detailing how to run the tool.
**Structuring the Sections**
I'm organizing the sections for the README.md. I've planned to include the project title and a badge to start. I'll follow with an introduction, a features list, and the necessary prerequisites. The installation instructions will follow, including explanations of what the commands do. I'm also considering a section on how it works.
**Enumerating Content**
I'm outlining the detailed content for the README.md. The project title and badges are set. I've listed the introduction and summary, emphasizing the interactive CLI nature. Feature specifics like multi-file selection and configuration persistence are noted. I'm also including detailed prerequisites, installation steps, usage instructions, a technical overview, updating and uninstallation procedures, and troubleshooting tips, along with a license. I'll ensure the README is available in Chinese as well. I am currently considering how to best use the edit\_file tool to add this structure.
</details></think>
---
好的,为这个项目编写一个详细的 README 文件是非常有必要的,它能帮助您自己和其他潜在的使用者快速了解项目的功能和用法。
我将为您创建一个 `README.md` 文件,其中会包含项目简介、功能特性、安装方法、使用说明、工作原理、卸载步骤以及常见问题排查等部分。
现在,我将为您生成 `README.md` 文件。
---
<details><summary>Edit file: README.md</summary>
I will create a new `README.md` file and populate it with a comprehensive guide for the Gitea Interactive Downloader project, including sections on features, installation, usage, how it works, updating, uninstallation, troubleshooting, and licensing, all formatted in Markdown.
**Chunk 1**
Lines added: 107, lines removed: 1
```diff
@@ -1,1 +1,107 @@
-
+ # Gitea 交互式下载器
+
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
+
+ 一个功能强大且用户友好的命令行工具,用于通过交互式菜单浏览和下载私有 Gitea 仓库中的文件。
+
+ ## ✨ 功能特性
+
+ - **🚀 一键安装**: 只需一行命令即可完成下载和安装,无需手动配置。
+ - **🤖 交互式操作**: 通过 `fzf` 驱动的 TUI 菜单,轻松浏览和选择仓库及文件。
+ - **📂 多文件选择**: 使用 `Tab` 键即可选中多个文件,进行批量下载。
+ - **⚙️ 智能配置**: 首次运行自动引导配置 Gitea 地址和访问令牌,并安全地保存在 `~/.gitea_cli_config`。
+ - **🛡️ `sudo` 感知**: 无论您是普通用户还是通过 `sudo` 运行,脚本都能自动找到正确的配置文件。
+ - **📦 依赖自检**: 在 Debian/Ubuntu 系统上,能自动检测并提示安装 `jq` 和 `fzf` 等必要依赖。
+ - **🌍 全局命令**: 安装后即可在系统任何路径下使用 `gitea` 命令。
+
+ ## 🔧 环境依赖
+
+ - **核心依赖**: `curl` (安装脚本需要,主程序也需要)
+ - **功能依赖**: `jq` (用于解析 JSON), `fzf` (用于生成交互式菜单)
+ - **支持系统**: 主要为 Linux (在 Debian/Ubuntu 上支持依赖自动安装)。在 macOS 或其他 Linux 发行版上,您可能需要手动安装 `jq` 和 `fzf`。
+
+ ## 🚀 安装
+
+ 您只需要在终端中运行以下一行命令,即可完成所有安装和配置:
+
+ ```bash
+ curl -sL https://git.zyj.best/theshy/gitea-downloader/raw/branch/main/install.sh | bash
+ ```
+
+ 此命令会:
+ 1. 下载最新的 `install.sh` 安装脚本。
+ 2. 通过管道 `|` 交给 `bash` 直接执行。
+ 3. 安装脚本会自动下载主程序 `gitea.sh`,将其重命名为 `gitea` 并移动到 `/usr/local/bin` 目录下,使其成为一个全局命令。
+
+ ## 💡 如何使用
+
+ 安装完成后,即可开始使用。
+
+ 1. **启动工具**
+ 在终端中输入以下命令:
+ ```bash
+ gitea down
+ ```
+
+ 2. **首次配置**
+ 如果是第一次运行,脚本会提示您输入:
+ - 您的 Gitea 实例 URL (例如 `https://git.example.com`)
+ - 您的 Gitea Access Token (访问令牌)
+
+ > **注意**: Access Token 需要至少拥有 `read:repository` 和 `read:user` 的权限。请在 Gitea 网站的 `设置 -> 应用` 页面生成。
+
+ 3. **交互式选择**
+ - **选择仓库**: 脚本会列出您的所有仓库,使用 `` `` 方向键导航,按 `Enter` 确认。
+ - **选择文件**: 接着会列出所选仓库中的所有文件。
+ - 使用 `` `` 导航。
+ - 使用 `Tab` 键选中或取消选中一个文件(选中的会高亮)。
+ - 按 `Enter` 键确认选择,开始下载。
+
+ ## 🛠️ 工作原理
+
+ 本项目包含两个核心脚本:
+
+ 1. `install.sh`: 一键安装脚本,负责将主程序部署到系统中。
+ 2. `gitea.sh`: 主程序,负责与 Gitea API 交互、提供 TUI 菜单并执行下载任务。
+
+ 所有用户配置URL 和 Token都存储在用户家目录下的 `~/.gitea_cli_config` 文件中,并设置了仅当前用户可读写的权限 (`600`) 以确保安全。
+
+ ## 🔄 更新
+
+ 如果您想更新到最新版本的 `gitea` 工具,只需**重新运行一遍安装命令**即可。安装脚本会提示您是否覆盖现有版本。
+
+ ```bash
+ curl -sL https://git.zyj.best/theshy/gitea-downloader/raw/branch/main/install.sh | bash
+ ```
+
+ ## 🗑️ 卸载
+
+ 如果您想从系统中移除此工具,请执行以下两个步骤:
+
+ 1. **删除主程序文件**:
+ ```bash
+ sudo rm /usr/local/bin/gitea
+ ```
+
+ 2. **删除配置文件** (此操作会移除您保存的 URL 和 Token):
+ ```bash
+ rm ~/.gitea_cli_config
+ ```
+
+ ## ❓ 常见问题排查
+
+ - **问题: 运行 `gitea down` 后提示 "无法获取仓库列表" 或 "用户不存在"**
+ - **原因**: 这几乎总是因为 Access Token 无效或权限不足。
+ - **解决方案**:
+ 1. 请重新生成一个 Token确保至少勾选了 `repository` 和 `user` 权限。
+ 2. 运行 `gitea down`,在提示 `是否使用此配置?` 时输入 `reset`,然后输入您的新 Token。
+
+ - **问题: 安装后运行 `gitea` 提示 "command not found"**
+ - **原因**: 您的 Shell 可能还没有加载新的命令路径。
+ - **解决方案**:
+ 1. 尝试关闭当前终端,然后打开一个新的终端窗口。
+ 2. 如果问题依旧,请检查 `/usr/local/bin` 是否在您的 `$PATH` 环境变量中 (`echo $PATH`)。
+
+ ## 📄 许可证
+
+ 本项目采用 [MIT](https://opensource.org/licenses/MIT) 许可证。
```
</details>
---
内容详尽的 `README.md` 文件已经为您创建好了。
这个文件全面地介绍了您的项目,从安装、使用到技术细节和问题排查,都给出了清晰的指引。它将作为您项目的一个优秀门面,让任何接触到它的人都能快速上手。
现在您的整个项目——包括功能脚本、安装脚本、Git 忽略文件和说明文档——都已准备就绪。您可以将它们全部提交并推送到您的 Gitea 仓库,一个完整且专业的项目就此诞生了!
---

112
README.md Normal file
View File

@ -0,0 +1,112 @@
# Gitea 交互式下载器
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
一个功能强大且用户友好的命令行工具,用于通过交互式菜单浏览和下载私有 Gitea 仓库中的文件。
## ✨ 功能特性
- **🚀 一键安装**: 只需一行命令即可完成下载和安装,无需手动配置。
- **🤖 交互式操作**: 通过 `fzf` 驱动的 TUI 菜单,轻松浏览和选择仓库及文件。
- **📂 多文件选择**: 使用 `Tab` 键即可选中多个文件,进行批量下载。
- **⚙️ 智能配置**: 首次运行自动引导配置 Gitea 地址和访问令牌,并安全地保存在 `~/.gitea_cli_config`
- **🛡️ `sudo` 感知**: 无论您是普通用户还是通过 `sudo` 运行,脚本都能自动找到正确的配置文件。
- **📦 依赖自检**: 在 Debian/Ubuntu 系统上,能自动检测并提示安装 `jq``fzf` 等必要依赖。
- **🌍 全局命令**: 安装后即可在系统任何路径下使用 `gitea` 命令。
## 🔧 环境依赖
- **核心依赖**: `curl` (安装脚本需要,主程序也需要)
- **功能依赖**: `jq` (用于解析 JSON), `fzf` (用于生成交互式菜单)
- **支持系统**: 主要为 Linux (在 Debian/Ubuntu 上支持依赖自动安装)。在 macOS 或其他 Linux 发行版上,您可能需要手动安装 `jq``fzf`
## 🚀 安装
您只需要在终端中运行以下一行命令,即可完成所有安装和配置:
```bash
curl -sL https://git.zyj.best/theshy/gitea-downloader/raw/branch/main/install.sh | bash
```
此命令会:
1. 下载最新的 `install.sh` 安装脚本。
2. 通过管道 `|` 交给 `bash` 直接执行。
3. 安装脚本会自动下载主程序 `gitea.sh`,将其重命名为 `gitea` 并移动到 `/usr/local/bin` 目录下,使其成为一个全局命令。
## 💡 如何使用
安装完成后,即可开始使用。
1. **启动工具**
在终端中输入以下命令:
```bash
gitea down
```
2. **首次配置**
如果是第一次运行,脚本会提示您输入:
- 您的 Gitea 实例 URL (例如 `https://git.example.com`)
- 您的 Gitea Access Token (访问令牌)
> **注意**: Access Token 需要至少拥有 `read:repository` 和 `read:user` 的权限。请在 Gitea 网站的 `设置 -> 应用` 页面生成。
3. **交互式选择**
- **选择仓库**: 脚本会列出您的所有仓库,使用 `` `` 方向键导航,按 `Enter` 确认。
- **选择文件**: 接着会列出所选仓库中的所有文件。
- 使用 `` `` 导航。
- 使用 `Tab` 键选中或取消选中一个文件(选中的会高亮)。
- 按 `Enter` 键确认选择,开始下载。
## 🛠️ 工作原理
本项目包含两个核心脚本:
1. `install.sh`: 一键安装脚本,负责将主程序部署到系统中。
2. `gitea.sh`: 主程序,负责与 Gitea API 交互、提供 TUI 菜单并执行下载任务。
所有用户配置URL 和 Token都存储在用户家目录下的 `~/.gitea_cli_config` 文件中,并设置了仅当前用户可读写的权限 (`600`) 以确保安全。
## 🔄 更新
如果您想更新到最新版本的 `gitea` 工具,只需**重新运行一遍安装命令**即可。安装脚本会提示您是否覆盖现有版本。
```bash
curl -sL https://git.zyj.best/theshy/gitea-downloader/raw/branch/main/install.sh | bash
```
## 🗑️ 卸载
如果您想从系统中移除此工具,请执行以下两个步骤:
1. **删除主程序文件**:
```bash
sudo rm /usr/local/bin/gitea
```
2. **删除配置文件** (此操作会移除您保存的 URL 和 Token):
```bash
rm ~/.gitea_cli_config
```
## ❓ 常见问题排查
- **问题: 运行 `gitea down` 后提示 "无法获取仓库列表" 或 "用户不存在"**
- **原因**: 这几乎总是因为 Access Token 无效或权限不足。
- **解决方案**:
1. 请重新生成一个 Token确保至少勾选了 `repository` 和 `user` 权限。
2. 运行 `gitea down`,在提示 `是否使用此配置?` 时输入 `reset`,然后输入您的新 Token。
- **问题: 安装后运行 `gitea` 提示 "command not found"**
- **原因**: 您的 Shell 可能还没有加载新的命令路径。
- **解决方案**:
1. 尝试关闭当前终端,然后打开一个新的终端窗口。
2. 如果问题依旧,请检查 `/usr/local/bin` 是否在您的 `$PATH` 环境变量中 (`echo $PATH`)。
## 📄 许可证
本项目采用 [MIT](https://opensource.org/licenses/MIT) 许可证。