diff --git a/demo/Dockerfile b/demo/Dockerfile index ae81f80c..6f5bb828 100644 --- a/demo/Dockerfile +++ b/demo/Dockerfile @@ -7,11 +7,12 @@ RUN set -eux; \ apt install --yes --no-install-recommends bind9-dnsutils iputils-ping iproute2 curl ca-certificates htop wget unzip openssh-server; \ apt clean autoclean; \ apt autoremove --yes; \ - wget https://github.com/tstack/lnav/releases/download/v0.11.0-beta2/lnav-0.11.0-musl-64bit.zip; \ - unzip lnav-0.11.0-musl-64bit.zip; \ rm -rf /var/lib/{apt,dpkg,cache,log}/; \ echo "Installed base utils!" +ADD https://github.com/tstack/lnav/releases/download/v0.11.0-beta2/lnav-0.11.0-musl-64bit.zip / +RUN unzip lnav-0.11.0-musl-64bit.zip + COPY docs/tutorials tutorials RUN useradd -rm -d /home/logs -s /bin/bash logs @@ -22,14 +23,20 @@ RUN useradd -rm -d /home/tutorial1 -s /bin/bash tutorial1 RUN echo 'tutorial1:tutorial1' | chpasswd RUN passwd -d tutorial1 +RUN useradd -rm -d /home/debug -s /bin/bash debug +RUN echo 'debug:debug' | chpasswd + USER tutorial1 RUN /lnav-0.11.0/lnav -nN -c ":config /ui/theme monocai" USER root -RUN echo 'ForceCommand env LNAVSECURE=1 TERM=xterm-256color /lnav-0.11.0/lnav -c ":switch-to-view text" -I /tutorials/tutorial-lib /tutorials/tutorial1/tutorial1.glog /tutorials/tutorial1/index.md#tutorial-1' >> /etc/ssh/sshd_config +RUN echo 'Match User logs' >> /etc/ssh/sshd_config +RUN echo 'ForceCommand env LNAVSECURE=1 TERM=xterm-256color /lnav-0.11.0/lnav -d /tmp/lnav.err /demo' >> /etc/ssh/sshd_config +RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config +RUN echo 'Match User tutorial1' >> /etc/ssh/sshd_config +RUN echo 'ForceCommand env PATH=/lnav-0.11.0:$PATH /tutorials/tutorial1/run.sh' >> /etc/ssh/sshd_config RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config -RUN cat /etc/ssh/sshd_config RUN service ssh start EXPOSE 22 diff --git a/docs/tutorials/tutorial1/run.sh b/docs/tutorials/tutorial1/run.sh new file mode 100755 index 00000000..294ea271 --- /dev/null +++ b/docs/tutorials/tutorial1/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export LNAVSECURE=1 +export TERM=xterm-256color + +lnav -I /tutorials/tutorial-lib /tutorials/tutorial1/tutorial1.glog /tutorials/tutorial1/index.md#tutorial-1 diff --git a/src/command_executor.cc b/src/command_executor.cc index 2c5de4ae..3d1a1afe 100644 --- a/src/command_executor.cc +++ b/src/command_executor.cc @@ -1106,6 +1106,15 @@ exec_context::execute(const std::string& cmdline) void exec_context::add_error_context(lnav::console::user_message& um) { + switch (um.um_level) { + case lnav::console::user_message::level::raw: + case lnav::console::user_message::level::info: + case lnav::console::user_message::level::ok: + return; + default: + break; + } + if (um.um_snippets.empty()) { um.with_snippets(this->ec_source); } diff --git a/src/lnav.cc b/src/lnav.cc index 2e850942..7c6fd644 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -1194,11 +1194,18 @@ looper() auto ecb_guard = lnav_data.ld_exec_context.add_error_callback([](const auto& um) { - lnav_data.ld_user_message_source.replace_with( - um.to_attr_line().rtrim()); - lnav_data.ld_user_message_view.reload_data(); - lnav_data.ld_user_message_expiration - = std::chrono::steady_clock::now() + 20s; + auto al = um.to_attr_line().rtrim(); + + if (al.get_string().find('\n') == std::string::npos) { + if (lnav_data.ld_rl_view) { + lnav_data.ld_rl_view->set_attr_value(al); + } + } else { + lnav_data.ld_user_message_source.replace_with(al); + lnav_data.ld_user_message_view.reload_data(); + lnav_data.ld_user_message_expiration + = std::chrono::steady_clock::now() + 20s; + } }); { diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index 4228a2c4..65249793 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -715,12 +715,14 @@ com_goto_mark(exec_context& ec, } if (!new_top) { - return ec.make_error( - "no more {} bookmarks after here", + auto um = lnav::console::user_message::info(fmt::format( + FMT_STRING("no more {} bookmarks after here"), fmt::join(mark_types | lnav::itertools::map( &bookmark_type_t::get_name), - ", ")); + ", "))); + + return Err(um); } } else { for (const auto& bt : mark_types) { @@ -733,7 +735,14 @@ com_goto_mark(exec_context& ec, } if (!new_top) { - return ec.make_error("no more bookmarks before here"); + auto um = lnav::console::user_message::info(fmt::format( + FMT_STRING("no more {} bookmarks before here"), + fmt::join(mark_types + | lnav::itertools::map( + &bookmark_type_t::get_name), + ", "))); + + return Err(um); } }