Skip to content

Commit 4f0b016

Browse files
committed
feat: add CLI support with command line arguments and server mode
1 parent b08877b commit 4f0b016

File tree

10 files changed

+548
-59
lines changed

10 files changed

+548
-59
lines changed

.goreleaser.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@
5555
- 提供 `hosts.txt`(纯文本)和 `hosts.json`(JSON)两种格式
5656
- 内置美观的 Web 页面,支持深色/浅色主题和多语言
5757

58+
### 命令行终端
59+
60+
[Releases](https://github.com/Licoy/fetch-github-hosts/releases) 中下载您的系统版本,可以直接通过命令行使用。
61+
62+
#### 参数
63+
64+
| 参数名 | 缩写 | 默认值 | 描述 |
65+
|--------|------|--------|------|
66+
| `--mode` | `-m` | 无(启动 GUI) | 启动模式:`client`(客户端)/ `server`(服务端) |
67+
| `--interval` | `-i` | `60` | 获取 hosts 的间隔时间(分钟) |
68+
| `--port` | `-p` | `9898` | 服务端模式监听端口 |
69+
| `--url` | `-u` | `https://hosts.gitcdn.top/hosts.txt` | 客户端模式远程 hosts 获取链接 |
70+
| `--lang` | `-l` | 自动检测 | 界面语言(`zh-CN``en-US``ja-JP`|
71+
72+
#### 启动客户端
73+
74+
```bash
75+
# Linux/macOS
76+
sudo ./fetch-github-hosts -m client
77+
78+
# Windows
79+
fetch-github-hosts.exe -m client
80+
81+
# 自定义获取间隔(10分钟)
82+
sudo ./fetch-github-hosts -m client -i 10
83+
84+
# 自定义获取链接
85+
sudo ./fetch-github-hosts -m client -u http://127.0.0.1:9898/hosts.json
86+
```
87+
88+
#### 启动服务端
89+
90+
```bash
91+
# Linux/macOS
92+
./fetch-github-hosts -m server
93+
94+
# Windows
95+
fetch-github-hosts.exe -m server
96+
97+
# 自定义端口
98+
./fetch-github-hosts -m server -p 6666
99+
```
100+
101+
> 💡 不指定 `-m` 参数时将启动图形化界面
102+
58103
### 手动方式
59104

60105
#### 添加 Hosts

README_EN.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@ Starts a local HTTP server that auto-resolves GitHub domains and serves hosts fi
5555
- Provides `hosts.txt` (plain text) and `hosts.json` (JSON) formats
5656
- Built-in web page with dark/light theme and multi-language support
5757

58+
### Command Line
59+
60+
Download your platform's binary from [Releases](https://github.com/Licoy/fetch-github-hosts/releases) and use it directly in the terminal.
61+
62+
#### Parameters
63+
64+
| Parameter | Short | Default | Description |
65+
|-----------|-------|---------|-------------|
66+
| `--mode` | `-m` | None (opens GUI) | Mode: `client` or `server` |
67+
| `--interval` | `-i` | `60` | Fetch interval in minutes |
68+
| `--port` | `-p` | `9898` | Server mode listening port |
69+
| `--url` | `-u` | `https://hosts.gitcdn.top/hosts.txt` | Client mode remote hosts URL |
70+
| `--lang` | `-l` | Auto-detect | Language (`zh-CN`, `en-US`, `ja-JP`) |
71+
72+
#### Start Client
73+
74+
```bash
75+
# Linux/macOS
76+
sudo ./fetch-github-hosts -m client
77+
78+
# Windows
79+
fetch-github-hosts.exe -m client
80+
81+
# Custom interval (every 10 minutes)
82+
sudo ./fetch-github-hosts -m client -i 10
83+
84+
# Custom URL
85+
sudo ./fetch-github-hosts -m client -u http://127.0.0.1:9898/hosts.json
86+
```
87+
88+
#### Start Server
89+
90+
```bash
91+
# Linux/macOS
92+
./fetch-github-hosts -m server
93+
94+
# Windows
95+
fetch-github-hosts.exe -m server
96+
97+
# Custom port
98+
./fetch-github-hosts -m server -p 6666
99+
```
100+
101+
> 💡 Omitting the `-m` parameter launches the graphical user interface
102+
58103
### Manual Method
59104

60105
#### Add Hosts

README_JA.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@
5555
- `hosts.txt`(プレーンテキスト)と `hosts.json`(JSON)の2形式を提供
5656
- ダーク/ライトテーマ・多言語対応の Web ページを内蔵
5757

58+
### コマンドライン
59+
60+
[Releases](https://github.com/Licoy/fetch-github-hosts/releases) からお使いのプラットフォーム用のバイナリをダウンロードし、ターミナルから直接使用できます。
61+
62+
#### パラメータ
63+
64+
| パラメータ | 短縮形 | デフォルト値 | 説明 |
65+
|-----------|--------|------------|------|
66+
| `--mode` | `-m` | なし(GUI起動) | モード: `client`(クライアント)/ `server`(サーバー) |
67+
| `--interval` | `-i` | `60` | hosts 取得間隔(分) |
68+
| `--port` | `-p` | `9898` | サーバーモードのリスニングポート |
69+
| `--url` | `-u` | `https://hosts.gitcdn.top/hosts.txt` | クライアントモードのリモート hosts URL |
70+
| `--lang` | `-l` | 自動検出 | 言語(`zh-CN``en-US``ja-JP`|
71+
72+
#### クライアント起動
73+
74+
```bash
75+
# Linux/macOS
76+
sudo ./fetch-github-hosts -m client
77+
78+
# Windows
79+
fetch-github-hosts.exe -m client
80+
81+
# カスタム間隔(10分ごと)
82+
sudo ./fetch-github-hosts -m client -i 10
83+
84+
# カスタム URL
85+
sudo ./fetch-github-hosts -m client -u http://127.0.0.1:9898/hosts.json
86+
```
87+
88+
#### サーバー起動
89+
90+
```bash
91+
# Linux/macOS
92+
./fetch-github-hosts -m server
93+
94+
# Windows
95+
fetch-github-hosts.exe -m server
96+
97+
# カスタムポート
98+
./fetch-github-hosts -m server -p 6666
99+
```
100+
101+
> 💡 `-m` パラメータを省略するとグラフィカルインターフェースが起動します
102+
58103
### 手動設定
59104

60105
#### Hosts の追加

src-tauri/Cargo.lock

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ dns-lookup = "2"
2929
chrono = "0.4"
3030
dirs = "6"
3131
sys-locale = "0.3.2"
32+
clap = { version = "4.5.58", features = ["derive"] }

0 commit comments

Comments
 (0)