Skip to content

Conversation

@Brijesh-Thakkar
Copy link

This PR adds a Python-like input() function to stdlib_io.

Features:

  • Reads a full line from standard input
  • Optional prompt support
  • Preserves trailing whitespace
  • No implicit type conversion
  • Integrates with existing get_line infrastructure

Documentation, examples, and tests are included.
All CMake and ctest checks pass locally.

Fixes #259

Copilot AI review requested due to automatic review settings December 14, 2025 00:45
Copy link
Contributor

Copilot AI left a 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() function to stdlib_io, providing a convenient way to read user input from standard input with an optional prompt. The implementation leverages the existing get_line infrastructure and follows similar patterns to other I/O functions in the module.

Key Changes

  • New input() function that reads a line from standard input with optional prompt support
  • Preserves trailing whitespace and returns an allocatable character string
  • Includes optional error handling via iostat and iomsg parameters

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/stdlib_io.fypp Adds the input_char function implementation and input interface, exports it in the public API
doc/specs/stdlib_io.md Adds comprehensive documentation for the new input function including syntax, arguments, return value, and usage notes
example/io/example_input.f90 Provides a basic usage example of the input() function
test/io/test_input.f90 Adds a test case for the input() function to verify whitespace preservation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brijesh-Thakkar
Copy link
Author

@jvdp1 Heyy, Please review this pr

@Brijesh-Thakkar
Copy link
Author

I will check why this one check is faling and commit the changes

@Brijesh-Thakkar
Copy link
Author

@jvdp1
I did the changees required for that CI check to pass, please review it.

Copy link
Member

@jvdp1 jvdp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Brijesh-Thakkar for this PR. Here are some comments.

!! - Preserves trailing whitespace
!! - Returns allocatable character string
!! - Does not perform type conversion
!! - Does not stop on error unless caller chooses to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I clarified this to explicitly describe the behavior in terms of iostat/iomsg handling instead of using a vague statemen

@Brijesh-Thakkar
Copy link
Author

@jvdp1 Thanks for the comments, I will work on them and let you know

@Brijesh-Thakkar
Copy link
Author

@jvdp1
Doen with the changes that you suggested to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input() function

2 participants