#train #timetable #cli #rodalies #catalunya

bin+lib rodalies-cli

罗达利斯列车时刻表命令行界面

14 个版本 (9 个稳定版本)

1.2.2 2024年3月30日
1.2.1 2023年12月1日
1.2.0 2023年10月1日
1.1.1 2023年6月22日
0.1.4 2022年7月31日

#225 in 命令行工具

每月42次下载

BSD-3-Clause

365KB
685

CICD

罗达利斯时刻表 CLI

在终端查看罗达利斯列车时刻表!

rodalies-cliRust 编写并发布到 crates.io,使用它您可以更快地获取时刻表,不再需要打开应用程序或浏览器。

从版本 1.0.0 开始,可以交互式搜索所需时刻表。此外,它还被重构为也可以作为一个库提供。

安装

发布版本二进制文件下载

发布后,github action 会更新它,包括为 x86_64 构建的二进制文件

  • Linux

运行以下命令以将二进制文件放入您的 bin 文件夹或按您喜欢的任何方式调整

curl -LO "https://github.com/gerardcl/rodalies-cli/releases/download/1.2.2/rodalies-cli-linux-amd64" && \
chmod +x rodalies-cli-linux-amd64 && mv rodalies-cli-linux-amd64 /usr/local/bin/rodalies-cli

注意您需要安装 libssl 或 openssl 开发包。

  • MacOS

运行以下命令以将二进制文件放入您的 bin 文件夹或按您喜欢的任何方式调整

curl -LO "https://github.com/gerardcl/rodalies-cli/releases/download/1.2.2/rodalies-cli-darwin-amd64" && \
chmod +x rodalies-cli-darwin-amd64 && mv rodalies-cli-darwin-amd64 /usr/local/bin/rodalies-cli

注意目前 github action 还不支持 M1 OS,因此对于 M1,请通过 cargo 安装(请参阅以下安装选项)。

  • Windows

运行以下命令以将二进制文件放入您的 bin 文件夹或按您喜欢的任何方式调整

curl -LO "https://github.com/gerardcl/rodalies-cli/releases/download/1.2.2/rodalies-cli-windows-amd64.exe" && \
chmod +x rodalies-cli-windows-amd64.exe && mv rodalies-cli-windows-amd64.exe /mingw64/bin/rodalies-cli.exe

注意预计该程序将在 Windows Git Bash 上运行良好,但您也可以在您的 CMD 或 PowerShell 上运行它。如果使用 WSL,则请参阅 Linux 安装说明。

Cargo 安装

  1. 您需要在您的系统上安装 rust,如果尚未安装,请访问 安装页面

  2. 现在使用 cargo 在您的 rust bin 文件夹上安装它

cargo install rodalies-cli

手动构建

  1. 您需要在您的系统上安装 rust,如果尚未安装,请访问 安装页面

  2. 克隆此仓库

git clone https://github.com/gerardcl/rodalies-cli.git
  1. 进入新克隆的仓库文件夹并

    • 使用 cargo 运行它
    cargo run -- --help
    
    • 或构建它并将二进制文件移动到您的 bin 文件夹
    cargo build --release
    cp target/release/rodalies-cli <to your preferred bin folder loctation>
    

用法

安装 rodalies-cli 后,只需运行帮助命令即可了解您可以做什么

$ rodalies-cli --help
CLI for searching train timetables of the trains of Rodalies de la Generalitat de Catalunya

Usage: rodalies-cli [OPTIONS]

Options:
  -i, --interactive      Enable interactive train timetable search. No value required.
  -s, --search <search>  Search the ID of a given station's name pattern, to later use it on your origin or destination. [env: RODALIES_CLI_SEARCH=]
  -f, --from <from>      The origin's station ID. [env: RODALIES_CLI_FROM=]
  -t, --to <to>          The destinations's station ID. [env: RODALIES_CLI_TO=]
  -d, --day <day>        The day value of the date to search for (default = today's day).
  -m, --month <month>    The month value of the date to search for (default = today's month).
  -y, --year <year>      The year value of the date to search for (default = today's year).
  -h, --help             Print help
  -V, --version          Print version

简单来说:可以直接运行裸命令以启动交互模式。如果不这样做,则需要手动使用车站 ID 定义您的出发地和目的地。为了知道这些 ID,您需要通过搜索文本模式来搜索它们。

只需键入裸命令即可

$ rodalies-cli
...

看看它是如何工作的

Interactive searching in action

注意:可以使用右边的标志指定另一个日期

$ rodalies-cli -d 9 -m 9
...

搜索车站 ID 和时刻表

  1. 首先搜索您的出发地和目的地车站的 ID
$ rodalies-cli -s gir
🚂 Rodalies CLI 📅 Today's date is 02/08/2022
✅ You are running the latest rodalies-cli, version 1.2.2! yayy
✨ Interactive mode enabled: 'false'
🔍 Searching stations that contain the text: 'gir'
+--------------+------------+
| Station name | Station ID |
+--------------+------------+
| Girona       |   79300    |
+--------------+------------+

$ rodalies-cli -s si
🚂 Rodalies CLI 📅 Today's date is 02/08/2022
 You are running the latest rodalies-cli, version 1.2.2! yayy
 Interactive mode enabled: 'false'
🔍 Searching stations that contain the text: 'si'
+------------------------+------------+
| Station name           | Station ID |
+------------------------+------------+
| Cerdanyola-Universitat |   72503    |
| Sils                   |   79202    |
| Sitges                 |   71701    |
+------------------------+------------+
  1. 搜索今天的时刻表
$ rodalies-cli -f 79300 -t 79202
🚂 Rodalies CLI 📅 Today's date is 02/08/2022
✅ You are running the latest rodalies-cli, version 1.2.2! yayy
✨ Interactive mode enabled: 'false'
🔍 Searching timetable for date 02/08/2022
📆 Listing timetable with 0 transfers
🌡 Expected temperatures at destination between 19º and 23º
+----------+-------+---------+-------+-------+---------+
| Duration | Train | Station | Start | End   | Station |
+----------+-------+---------+-------+-------+---------+
| 00:18    | R11   | Girona  | 06:04 | 06:22 | Sils    |
| 00:19    | R11   | Girona  | 06:19 | 06:38 | Sils    |
| 00:21    | RG1   | Girona  | 06:33 | 06:54 | Sils    |
| 00:18    | R11   | Girona  | 07:09 | 07:27 | Sils    |
| 00:16    | R11   | Girona  | 07:44 | 08:00 | Sils    |
| 00:19    | R11   | Girona  | 08:09 | 08:28 | Sils    |
| 00:19    | RG1   | Girona  | 08:40 | 08:59 | Sils    |
| 00:16    | R11   | Girona  | 08:49 | 09:05 | Sils    |
| 00:19    | R11   | Girona  | 09:39 | 09:58 | Sils    |
| 00:16    | R11   | Girona  | 10:19 | 10:35 | Sils    |
| 00:19    | RG1   | Girona  | 10:42 | 11:01 | Sils    |
| 00:19    | R11   | Girona  | 11:39 | 11:58 | Sils    |
| 00:16    | R11   | Girona  | 12:19 | 12:35 | Sils    |
| 00:19    | RG1   | Girona  | 12:42 | 13:01 | Sils    |
| 00:19    | R11   | Girona  | 13:39 | 13:58 | Sils    |
| 00:16    | R11   | Girona  | 14:19 | 14:35 | Sils    |
| 00:19    | RG1   | Girona  | 14:41 | 15:00 | Sils    |
| 00:16    | R11   | Girona  | 14:49 | 15:05 | Sils    |
| 00:19    | R11   | Girona  | 15:39 | 15:58 | Sils    |
| 00:16    | R11   | Girona  | 16:19 | 16:35 | Sils    |
| 00:19    | RG1   | Girona  | 16:42 | 17:01 | Sils    |
| 00:19    | R11   | Girona  | 17:09 | 17:28 | Sils    |
| 00:16    | R11   | Girona  | 17:49 | 18:05 | Sils    |
| 00:16    | R11   | Girona  | 18:19 | 18:35 | Sils    |
| 00:19    | R11   | Girona  | 18:39 | 18:58 | Sils    |
| 00:16    | R11   | Girona  | 19:19 | 19:35 | Sils    |
| 00:19    | RG1   | Girona  | 19:42 | 20:01 | Sils    |
| 00:19    | R11   | Girona  | 20:09 | 20:28 | Sils    |
| 00:19    | RG1   | Girona  | 20:42 | 21:01 | Sils    |
| 00:16    | R11   | Girona  | 20:59 | 21:15 | Sils    |
| 00:16    | R11   | Girona  | 21:19 | 21:35 | Sils    |
+----------+-------+---------+-------+-------+---------+

多次传输

如果时间表需要中转,您也会看到它

$ rodalies-cli -f 79300 -t 71701
🚂 Rodalies CLI 📅 Today's date is 02/08/2022
✅ You are running the latest rodalies-cli, version 1.2.2! yayy
✨ Interactive mode enabled: 'false'
🔍 Searching timetable for date 02/08/2022
📆 Listing timetable with 1 transfers
🌡 Expected temperatures at destination between 23º and 25º
+----------+-------+---------+-------+-------+-----------------+--------+-------+-------+-------+---------+
| Duration | Train | Station | Start | Stop  | Transfer        | Wait   | Train | Start | End   | Station |
+----------+-------+---------+-------+-------+-----------------+--------+-------+-------+-------+---------+
| 02:18    | R11   | Girona  | 06:04 | 07:40 | Barcelona-Sants | 5 min  | R2    | 07:45 | 08:22 | Sitges  |
| 02:18    | R11   | Girona  | 06:19 | 07:55 | Barcelona-Sants | 11 min | R2    | 08:06 | 08:37 | Sitges  |
| 02:13    | R11   | Girona  | 07:09 | 08:40 | Barcelona-Sants | 5 min  | R2    | 08:45 | 09:22 | Sitges  |
| 02:08    | R11   | Girona  | 07:44 | 09:10 | Barcelona-Sants | 5 min  | R2    | 09:15 | 09:52 | Sitges  |
| 02:13    | R11   | Girona  | 08:09 | 09:40 | Barcelona-Sants | 5 min  | R2    | 09:45 | 10:22 | Sitges  |
| 02:03    | R11   | Girona  | 08:49 | 10:10 | Barcelona-Sants | 5 min  | R2    | 10:15 | 10:52 | Sitges  |
| 02:13    | R11   | Girona  | 09:39 | 11:10 | Barcelona-Sants | 5 min  | R2    | 11:15 | 11:52 | Sitges  |
| 02:03    | R11   | Girona  | 10:19 | 11:40 | Barcelona-Sants | 5 min  | R2    | 11:45 | 12:22 | Sitges  |
| 02:55    | RG1   | Girona  | 10:42 | 12:48 | Barcelona-Sants | 18 min | R2    | 13:06 | 13:37 | Sitges  |
| 02:13    | R11   | Girona  | 11:39 | 13:10 | Barcelona-Sants | 5 min  | R2    | 13:15 | 13:52 | Sitges  |
| 02:03    | R11   | Girona  | 12:19 | 13:40 | Barcelona-Sants | 5 min  | R2    | 13:45 | 14:22 | Sitges  |
| 02:55    | RG1   | Girona  | 12:42 | 14:48 | Barcelona-Sants | 18 min | R2    | 15:06 | 15:37 | Sitges  |
| 02:13    | R11   | Girona  | 13:39 | 15:10 | Barcelona-Sants | 5 min  | R2    | 15:15 | 15:52 | Sitges  |
| 02:03    | R11   | Girona  | 14:19 | 15:40 | Barcelona-Sants | 5 min  | R2    | 15:45 | 16:22 | Sitges  |
| 02:03    | R11   | Girona  | 14:49 | 16:10 | Barcelona-Sants | 5 min  | R2    | 16:15 | 16:52 | Sitges  |
| 02:13    | R11   | Girona  | 15:39 | 17:10 | Barcelona-Sants | 5 min  | R2    | 17:15 | 17:52 | Sitges  |
| 02:03    | R11   | Girona  | 16:19 | 17:40 | Barcelona-Sants | 5 min  | R2    | 17:45 | 18:22 | Sitges  |
| 02:13    | R11   | Girona  | 17:09 | 18:40 | Barcelona-Sants | 5 min  | R2    | 18:45 | 19:22 | Sitges  |
| 02:03    | R11   | Girona  | 17:49 | 19:10 | Barcelona-Sants | 5 min  | R2    | 19:15 | 19:52 | Sitges  |
| 02:03    | R11   | Girona  | 18:19 | 19:40 | Barcelona-Sants | 5 min  | R2    | 19:45 | 20:22 | Sitges  |
| 02:13    | R11   | Girona  | 18:39 | 20:10 | Barcelona-Sants | 5 min  | R2    | 20:15 | 20:52 | Sitges  |
| 02:03    | R11   | Girona  | 19:19 | 20:40 | Barcelona-Sants | 5 min  | R2    | 20:45 | 21:22 | Sitges  |
| 02:13    | R11   | Girona  | 20:09 | 21:40 | Barcelona-Sants | 5 min  | R2    | 21:45 | 22:22 | Sitges  |
| 02:14    | R11   | Girona  | 20:59 | 22:20 | Barcelona-Sants | 14 min | R2    | 22:34 | 23:13 | Sitges  |
| 02:18    | R11   | Girona  | 21:19 | 22:40 | Barcelona-Sants | 24 min | R2    | 23:04 | 23:37 | Sitges  |
+----------+-------+---------+-------+-------+-----------------+--------+-------+-------+-------+---------+

注意:表格的宽度将根据时间表中传输的数量相应增加。

$ rodalies-cli -f 79300 -t 72503
🚂 Rodalies CLI 📅 Today's date is 02/08/2022
✅ You are running the latest rodalies-cli, version 1.2.2! yayy
✨ Interactive mode enabled: 'false'
🔍 Searching timetable for date 02/08/2022
📆 Listing timetable with 2 transfers
🌡 Expected temperatures at destination between 19º and 23º
+----------+-------+---------+-------+-------+-----------------+--------+-------+-------+-------+------------------------------+-------+-------+-------+-------+------------------------+
| Duration | Train | Station | Start | Stop  | Transfer        | Wait   | Train | Start | Stop  | Transfer                     | Wait  | Train | Start | End   | Station                |
+----------+-------+---------+-------+-------+-----------------+--------+-------+-------+-------+------------------------------+-------+-------+-------+-------+------------------------+
| 02:18    | R11   | Girona  | 06:04 | 07:40 | Barcelona-Sants | 3 min  | R4    | 07:43 | 07:59 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 08:03 | 08:22 | Cerdanyola-Universitat |
| 02:25    | R11   | Girona  | 06:19 | 07:55 | Barcelona-Sants | 6 min  | R3    | 08:01 | 08:17 | Barcelona-Sant Andreu Arenal | 7 min | R7    | 08:24 | 08:44 | Cerdanyola-Universitat |
| 02:33    | R11   | Girona  | 06:19 | 07:55 | Barcelona-Sants | 18 min | R4    | 08:13 | 08:29 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 08:33 | 08:52 | Cerdanyola-Universitat |
| 02:55    | R11   | Girona  | 06:19 | 07:55 | Barcelona-Sants | 36 min | R3    | 08:31 | 08:47 | Barcelona-Sant Andreu Arenal | 7 min | R7    | 08:54 | 09:14 | Cerdanyola-Universitat |
| 03:03    | R11   | Girona  | 06:19 | 07:55 | Barcelona-Sants | 48 min | R4    | 08:43 | 08:59 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 09:03 | 09:22 | Cerdanyola-Universitat |
| 02:35    | R11   | Girona  | 07:09 | 08:40 | Barcelona-Sants | 21 min | R3    | 09:01 | 09:17 | Barcelona-Sant Andreu Arenal | 7 min | R7    | 09:24 | 09:44 | Cerdanyola-Universitat |
| 02:43    | R11   | Girona  | 07:09 | 08:40 | Barcelona-Sants | 33 min | R4    | 09:13 | 09:29 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 09:33 | 09:52 | Cerdanyola-Universitat |
| 02:26    | R11   | Girona  | 07:44 | 09:10 | Barcelona-Sants | 21 min | R3    | 09:31 | 09:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 09:51 | 10:10 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 08:09 | 09:40 | Barcelona-Sants | 21 min | R3    | 10:01 | 10:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 10:21 | 10:40 | Cerdanyola-Universitat |
| 03:01    | R11   | Girona  | 08:09 | 09:40 | Barcelona-Sants | 51 min | R3    | 10:31 | 10:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 10:51 | 11:10 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 08:49 | 10:10 | Barcelona-Sants | 51 min | R3    | 11:01 | 11:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 11:21 | 11:40 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 09:39 | 11:10 | Barcelona-Sants | 21 min | R3    | 11:31 | 11:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 11:51 | 12:10 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 10:19 | 11:40 | Barcelona-Sants | 21 min | R3    | 12:01 | 12:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 12:21 | 12:40 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 10:19 | 11:40 | Barcelona-Sants | 51 min | R3    | 12:31 | 12:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 12:51 | 13:10 | Cerdanyola-Universitat |
| 02:58    | RG1   | Girona  | 10:42 | 12:48 | Barcelona-Sants | 13 min | R3    | 13:01 | 13:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 13:21 | 13:40 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 11:39 | 13:10 | Barcelona-Sants | 21 min | R3    | 13:31 | 13:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 13:51 | 14:10 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 12:19 | 13:40 | Barcelona-Sants | 21 min | R3    | 14:01 | 14:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 14:21 | 14:40 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 12:19 | 13:40 | Barcelona-Sants | 51 min | R3    | 14:31 | 14:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 14:51 | 15:10 | Cerdanyola-Universitat |
| 02:58    | RG1   | Girona  | 12:42 | 14:48 | Barcelona-Sants | 13 min | R3    | 15:01 | 15:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 15:21 | 15:40 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 13:39 | 15:10 | Barcelona-Sants | 21 min | R3    | 15:31 | 15:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 15:51 | 16:10 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 14:19 | 15:40 | Barcelona-Sants | 21 min | R3    | 16:01 | 16:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 16:21 | 16:40 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 14:19 | 15:40 | Barcelona-Sants | 51 min | R3    | 16:31 | 16:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 16:51 | 17:10 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 14:49 | 16:10 | Barcelona-Sants | 51 min | R3    | 17:01 | 17:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 17:21 | 17:40 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 15:39 | 17:10 | Barcelona-Sants | 21 min | R3    | 17:31 | 17:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 17:51 | 18:10 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 16:19 | 17:40 | Barcelona-Sants | 21 min | R3    | 18:01 | 18:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 18:21 | 18:40 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 16:19 | 17:40 | Barcelona-Sants | 51 min | R3    | 18:31 | 18:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 18:51 | 19:10 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 17:09 | 18:40 | Barcelona-Sants | 21 min | R3    | 19:01 | 19:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 19:21 | 19:40 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 17:49 | 19:10 | Barcelona-Sants | 21 min | R3    | 19:31 | 19:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 19:51 | 20:10 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 18:19 | 19:40 | Barcelona-Sants | 21 min | R3    | 20:01 | 20:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 20:21 | 20:40 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 18:39 | 20:10 | Barcelona-Sants | 21 min | R3    | 20:31 | 20:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 20:51 | 21:10 | Cerdanyola-Universitat |
| 02:21    | R11   | Girona  | 19:19 | 20:40 | Barcelona-Sants | 21 min | R3    | 21:01 | 21:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 21:21 | 21:40 | Cerdanyola-Universitat |
| 02:51    | R11   | Girona  | 19:19 | 20:40 | Barcelona-Sants | 51 min | R3    | 21:31 | 21:47 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 21:51 | 22:10 | Cerdanyola-Universitat |
| 02:31    | R11   | Girona  | 20:09 | 21:40 | Barcelona-Sants | 21 min | R3    | 22:01 | 22:17 | Barcelona-Sant Andreu Arenal | 4 min | R7    | 22:21 | 22:40 | Cerdanyola-Universitat |
+----------+-------+---------+-------+-------+-----------------+--------+-------+-------+-------+------------------------------+-------+-------+-------+-------+------------------------+

问题

请,如果您发现任何问题或想添加新功能,请打开一个问题。也欢迎贡献!

依赖项

~19–32MB
~494K SLoC