Skip to content
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

Use command line arguments as initial text in interactive example #255

Merged
merged 1 commit into from
Dec 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ mod unix_only {

let mut idx_iter = (0..splitters.len()).collect::<Vec<_>>().into_iter().cycle();

let mut text = String::from(
"Welcome to the interactive demo! The following is from The \
let args = std::env::args().collect::<Vec<_>>();
let mut text = if args.len() > 1 {
args[1..].join(" ")
} else {
String::from(
"Welcome to the interactive demo! The following is from The \
Emperor’s New Clothes by Hans Christian Andersen. You can edit the \
text!\n\n\
Many years ago there was an Emperor, who was so excessively fond \
Expand All @@ -270,7 +274,8 @@ mod unix_only {
as one does about any other king or emperor, ‘He is in his council \
chamber,’ here one always said, ‘The Emperor is in his \
dressing-room.’",
);
)
};

let stdin = io::stdin();
let mut screen = AlternateScreen::from(io::stdout().into_raw_mode()?);
Expand Down