- 
                Notifications
    You must be signed in to change notification settings 
- Fork 126
          Add option to set from stdin using railway variables
          #676
        
          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
base: master
Are you sure you want to change the base?
  
    Add option to set from stdin using railway variables
  
  #676
              Conversation
| _ => bail!(RailwayError::NoServiceLinked), | ||
| }; | ||
|  | ||
| if args.set_from_stdin { | 
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.
Would be nice to handle the case where users forget to pipe, so we don't hang forever. Maybe something like this:
| if args.set_from_stdin { | |
| if args.set_from_stdin { | |
| if std::io::stdin().is_terminal() { | |
| bail!("--set-from-stdin requires input from stdin (e.g., via pipe or redirect)"); | |
| } | 
| let line = line?; | ||
|  | ||
| if !line.trim().is_empty() { | ||
| args.set.push(line); | 
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.
Not super important b/c we trim later, but maybe this for consistency
| args.set.push(line); | |
| args.set.push(line.trim().to_string()); | 
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.
Couple small things but otherwise LGTM. I think being able to do:
echo "TEST=123" | cargo run variables
W/o the flag is a little cleaner, but I think what you have with an explicit flag is probably best here for backwards compat
Resolves #635.