// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/SshSessionContext.java
// public enum SshSessionContext {
// 
//     ;
// 
//     private static final ThreadLocal<Supplier<File>> USER_DIR_CONTEXT = new ThreadLocal<Supplier<File>>();
//     private static final ThreadLocal<Map<String, Object>> THREAD_CONTEXT = new ThreadLocal<Map<String, Object>>() {
//         @Override
//         protected Map<String, Object> initialValue() {
//             return new HashMap<>();
//         }
//     };
// 
//     public static void put(String key, Object value) {
//         THREAD_CONTEXT.get().put(key, value);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E get(String key) {
//         return (E) THREAD_CONTEXT.get().get(key);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E remove(String key) {
//         return (E) THREAD_CONTEXT.get().remove(key);
//     }
// 
//     public static boolean containsKey(String key) {
//         return THREAD_CONTEXT.get().containsKey(key);
//     }
// 
//     public static boolean isEmpty() {
//         return THREAD_CONTEXT.get().isEmpty();
//     }
// 
//     public static void clear() {
//         THREAD_CONTEXT.remove();
//         USER_DIR_CONTEXT.remove();
//     }
// 
//     public static void setUserDir(Supplier<File> userDirSupplier) {
//         USER_DIR_CONTEXT.set(userDirSupplier);
//     }
// 
//     public static File getUserDir() {
//         return USER_DIR_CONTEXT.get().get();
//     }
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/util/JsonUtils.java
// @lombok.extern.slf4j.Slf4j
// public enum JsonUtils {
//     ;
//     
//     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().findAndRegisterModules();
//     private static final ObjectWriter WRITER = OBJECT_MAPPER.writer().withDefaultPrettyPrinter();
//     
//     public static String asJson(Object object) {
//         try {
//             return WRITER.writeValueAsString(object);
//         } catch (JsonProcessingException ex) {
//             log.error("Error processing json output", ex);
//             return "Error processing json output: " + ex.getMessage();
//         }
//     }
// 
//     public static <E> E stringToObject(String json, Class<E> clazz) throws IOException {
//         return OBJECT_MAPPER.readValue(json, clazz);
//     }
// }


import java.io.IOException;
import java.util.Objects;
import org.jline.reader.LineReader;
import org.jline.terminal.Terminal;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import sshd.shell.springboot.autoconfiguration.SshSessionContext;
import sshd.shell.springboot.util.JsonUtils;
/*
 * Copyright 2017 anand.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package sshd.shell.springboot.console;


/**
 *
 * @author anand
 */
@lombok.extern.slf4j.Slf4j
public enum ConsoleIO {
    ;

    static final String LINE_READER = "__lineReader";
    static final String TEXT_STYLE = "__textStyle";
    static final String TERMINAL = "__terminal";
    static final String HIGHLIGHT_COLOR = "__highlightColor";

    /**
     * Read input from line with mask. Use null if input is to be echoed. Use 0 if nothing is to be echoed and other
     * characters that get echoed with input
     *
     * @param text Text to show
     * @param mask mask
     * @return input from user
     * @throws IOException if any
     */
    public static String readInput(String text, Character mask) throws IOException {
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/autoconfiguration/SshSessionContext.java
// public enum SshSessionContext {
// 
//     ;
// 
//     private static final ThreadLocal<Supplier<File>> USER_DIR_CONTEXT = new ThreadLocal<Supplier<File>>();
//     private static final ThreadLocal<Map<String, Object>> THREAD_CONTEXT = new ThreadLocal<Map<String, Object>>() {
//         @Override
//         protected Map<String, Object> initialValue() {
//             return new HashMap<>();
//         }
//     };
// 
//     public static void put(String key, Object value) {
//         THREAD_CONTEXT.get().put(key, value);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E get(String key) {
//         return (E) THREAD_CONTEXT.get().get(key);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public static <E> E remove(String key) {
//         return (E) THREAD_CONTEXT.get().remove(key);
//     }
// 
//     public static boolean containsKey(String key) {
//         return THREAD_CONTEXT.get().containsKey(key);
//     }
// 
//     public static boolean isEmpty() {
//         return THREAD_CONTEXT.get().isEmpty();
//     }
// 
//     public static void clear() {
//         THREAD_CONTEXT.remove();
//         USER_DIR_CONTEXT.remove();
//     }
// 
//     public static void setUserDir(Supplier<File> userDirSupplier) {
//         USER_DIR_CONTEXT.set(userDirSupplier);
//     }
// 
//     public static File getUserDir() {
//         return USER_DIR_CONTEXT.get().get();
//     }
// }
// 
// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/util/JsonUtils.java
// @lombok.extern.slf4j.Slf4j
// public enum JsonUtils {
//     ;
//     
//     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().findAndRegisterModules();
//     private static final ObjectWriter WRITER = OBJECT_MAPPER.writer().withDefaultPrettyPrinter();
//     
//     public static String asJson(Object object) {
//         try {
//             return WRITER.writeValueAsString(object);
//         } catch (JsonProcessingException ex) {
//             log.error("Error processing json output", ex);
//             return "Error processing json output: " + ex.getMessage();
//         }
//     }
// 
//     public static <E> E stringToObject(String json, Class<E> clazz) throws IOException {
//         return OBJECT_MAPPER.readValue(json, clazz);
//     }
// }


// Path: sshd-shell-spring-boot-starter/src/main/java/sshd/shell/springboot/console/ConsoleIO.java
import java.io.IOException;
import java.util.Objects;
import org.jline.reader.LineReader;
import org.jline.terminal.Terminal;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
import sshd.shell.springboot.autoconfiguration.SshSessionContext;
import sshd.shell.springboot.util.JsonUtils;

/*
 * Copyright 2017 anand.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package sshd.shell.springboot.console;


/**
 *
 * @author anand
 */
@lombok.extern.slf4j.Slf4j
public enum ConsoleIO {
    ;

    static final String LINE_READER = "__lineReader";
    static final String TEXT_STYLE = "__textStyle";
    static final String TERMINAL = "__terminal";
    static final String HIGHLIGHT_COLOR = "__highlightColor";

    /**
     * Read input from line with mask. Use null if input is to be echoed. Use 0 if nothing is to be echoed and other
     * characters that get echoed with input
     *
     * @param text Text to show
     * @param mask mask
     * @return input from user
     * @throws IOException if any
     */
    public static String readInput(String text, Character mask) throws IOException {
        LineReader reader = SshSessionContext.<LineReader>get(LINE_READER);