Provide pty info
- Enhance ShellContext for pty info - Enhance CommandContext to include ShellContext - Fixes #985
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022 the original author or authors.
|
||||
* Copyright 2022-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package org.springframework.shell.boot;
|
||||
|
||||
import org.jline.terminal.Terminal;
|
||||
import org.jline.terminal.spi.TerminalExt;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.shell.context.DefaultShellContext;
|
||||
@@ -24,7 +27,11 @@ import org.springframework.shell.context.ShellContext;
|
||||
public class ShellContextAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public ShellContext shellContext() {
|
||||
return new DefaultShellContext();
|
||||
public ShellContext shellContext(Terminal terminal) {
|
||||
boolean pty = false;
|
||||
if (terminal instanceof TerminalExt ext) {
|
||||
pty = ext.getSystemStream() != null;
|
||||
}
|
||||
return new DefaultShellContext(pty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022-2023 the original author or authors.
|
||||
* Copyright 2022-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class CommandCatalogAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class, ShellContextAutoConfiguration.class));
|
||||
.withConfiguration(AutoConfigurations.of(CommandCatalogAutoConfiguration.class,
|
||||
JLineShellAutoConfiguration.class, ShellContextAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void defaultCommandCatalog() {
|
||||
|
||||
Reference in New Issue
Block a user