Skip to content

Commit

Permalink
Use command line arguments as initial text in interactive example
Browse files Browse the repository at this point in the history
This makes it super easy to repeatedly test with a custom text.
  • Loading branch information
mgeisler committed Dec 13, 2020
1 parent 62f2b68 commit 342bdd0
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 342bdd0

Please sign in to comment.