From e7129590622595b87513b6279f8d8bd76c21ba24 Mon Sep 17 00:00:00 2001 From: Gerard CL Date: Sat, 19 Sep 2026 21:27:17 +0200 Subject: [PATCH] fix: python CLI without args show help message --- CHANGELOG.md | 4 ++++ Cargo.lock | 2 +- Cargo.toml | 2 +- Justfile | 2 +- src/cli.rs | 16 ++++++++++------ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe5d7f4..6a0dbcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v6.3.1 (2026-09-15) + +* Python CLI does not show help message when no args are provided [#214](https://github.com/gerardcl/renfe-cli/issues/214) + ## v6.3.0 (2026-09-14) * Enable version flag and version status check [#180](https://github.com/gerardcl/renfe-cli/issues/180) diff --git a/Cargo.lock b/Cargo.lock index 38be7e2..6e73dd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1198,7 +1198,7 @@ dependencies = [ [[package]] name = "renfe-cli" -version = "6.3.0" +version = "6.3.1" dependencies = [ "bincode", "chrono", diff --git a/Cargo.toml b/Cargo.toml index ce2a044..5fb5f48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "renfe-cli" -version = "6.3.0" +version = "6.3.1" edition = "2024" rust-version = "1.98" authors = ["Gerard C.L. "] diff --git a/Justfile b/Justfile index cf0d0e4..9cb6fd8 100644 --- a/Justfile +++ b/Justfile @@ -34,7 +34,7 @@ setup-hooks: # Run the development CLI through the local virtual environment. run *args: - uv run renfe-cli {{args}} + uv run --no-sync renfe-cli {{args}} # Open a Python shell in the development environment. python: diff --git a/src/cli.rs b/src/cli.rs index e0dfc37..e53c826 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,7 @@ use chrono::{Datelike, Utc}; use getopts::Options; -use pyo3::{PyResult, exceptions::PyValueError, pyfunction}; +use pyo3::types::PyAnyMethods; +use pyo3::{PyResult, Python, exceptions::PyValueError, pyfunction}; use std::env; use std::io::{self, BufRead, Write}; @@ -8,16 +9,19 @@ use crate::renfe::{Renfe, Station}; use crate::version::{Registry, print_version_status}; #[pyfunction] -pub fn main() -> PyResult<()> { - run(Registry::PyPi) +pub fn main(py: Python<'_>) -> PyResult<()> { + let args = py + .import("sys")? + .getattr("argv")? + .extract::>()?; + run(Registry::PyPi, args) } pub fn native_main() -> PyResult<()> { - run(Registry::CratesIo) + run(Registry::CratesIo, env::args().collect()) } -fn run(registry: Registry) -> PyResult<()> { - let args: Vec = env::args().collect(); +fn run(registry: Registry, args: Vec) -> PyResult<()> { let program = args[0].clone(); let now = Utc::now(); let opts = set_opts();