More fixes to stdin input.

Adding tty makes sure docker attach won't be accidentally detached
by ctrl-C (there are better ways of doing this but this one works
for now)

shell-words more closely emulates Bash's tokenizer rules (but without
doing things like environment variable expansion) which allows us to use
multiline strings as reasons, etc.  Unfortunately entering newlines
still won't work the way we've written things since shell-words does not
right now give enough information to incrementally build up a valid
string, just says there was a tokenizing error; but maybe in the future
we can fix that.
This commit is contained in:
Joshua Yanovski 2021-05-11 04:13:22 -07:00
parent 3f4ff839bb
commit 33494c0e29
4 changed files with 10 additions and 1 deletions

7
Cargo.lock generated
View File

@ -4595,6 +4595,12 @@ dependencies = [
"libc",
]
[[package]]
name = "shell-words"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
[[package]]
name = "shellexpand"
version = "2.1.0"
@ -5783,6 +5789,7 @@ dependencies = [
"num_cpus",
"ron",
"serde",
"shell-words",
"signal-hook 0.3.8",
"structopt",
"tokio",

View File

@ -35,6 +35,7 @@ structopt = "0.3.13"
crossterm = "0.19"
lazy_static = "1"
signal-hook = "0.3.6"
shell-words = "1.0.0"
tracing = { version = "0.1", default-features = false }
ron = {version = "0.6", default-features = false}
serde = {version = "1.0", features = [ "rc", "derive" ]}

View File

@ -4,6 +4,7 @@ services:
game-server:
image: registry.gitlab.com/veloren/veloren/server-cli:nightly
stdin_open: true
tty: true
container_name: veloren-game-server-master
ports:
- "14004:14004"

View File

@ -120,7 +120,7 @@ pub struct ArgvApp {
}
pub fn parse_command(input: &str, msg_s: &mut Sender<Message>) {
match TuiApp::from_iter_safe(input.split_whitespace()) {
match TuiApp::from_iter_safe(shell_words::split(input).unwrap_or_default()) {
Ok(message) => {
msg_s
.send(message.command)