-
Notifications
You must be signed in to change notification settings - Fork 208
Add input() convenience function to stdlib_io with documentation, tests, and example (Fixes #259) #1067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add input() convenience function to stdlib_io with documentation, tests, and example (Fixes #259) #1067
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a Python-like input() convenience function to stdlib_io for reading user input from standard input with an optional prompt. The implementation reuses the existing get_line_input_char infrastructure and follows the module's error handling patterns. The addition includes documentation, an example program, and basic compilation tests.
Key Changes
- New
input(prompt, stat)function that displays an optional prompt and reads a line from stdin - Example program demonstrating both simple usage and error handling with status checking
- Documentation section describing the new function with syntax and usage examples
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/stdlib_io.fypp | Adds input_character function implementation and interface, plus general whitespace cleanup throughout the file |
| test/io/test_input.f90 | Adds basic compilation test for the new function |
| test/io/CMakeLists.txt | Registers the new test in the build system |
| example/io/example_input.f90 | Provides example demonstrating simple and error-checked usage |
| example/io/CMakeLists.txt | Builds the example executable (not run as test due to interactive nature) |
| doc/specs/stdlib_io.md | Documents the new function with status, description, syntax, and examples |
| .gitignore | Adds .venv/ for Python virtual environment directories |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This commit adds a minimal Python-like input(prompt, iostat) convenience function to stdlib_io. Files changed: - src/stdlib_io.fypp: new generic interface and input_character implementation - doc/specs/stdlib_io.md: documentation, Arguments and examples - test/io/test_input.f90: compilation + CI-safe functional tests - test/io/CMakeLists.txt: register input tests - example/io/example_input.f90: example Behavior: - Optional prompt printed without newline - Trailing whitespace preserved - Optional iostat returns 0 on success, non-zero on EOF/I/O error - If iostat not provided, follows stdlib error semantics and calls error_stop on error This fixes Issue fortran-lang#259.
|
@Brijesh-Thakkar what was the reason to close this PR? |
|
@jvdp1 Actually i messed up things in this pr, so i would make a new pr |
|
Ok. Good. Don't hesitate to ping me when you will be ready |
|
@jvdp1 Yaa sure, I will ping you whenever I make PR for this issue |
Adds a minimal Python-like input(prompt, stat) function to stdlib_io.
Reads a full line, optional prompt + optional stat, follows stdlib error semantics, no parsing.
Includes docs, tests, example, and CMake updates.
Small, safe, ergonomic addition aligned with stdlib goals.
Ready for review.