# frozen_string_literal: true
#
# Copyright (c) 2021-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# ronin-core is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-core is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-core. If not, see .
#
require 'ronin/core/cli/banner'
require 'command_kit/printing'
require 'command_kit/colors'
require 'reline'
module Ronin
module Core
module CLI
#
# Base class for all interactive CLI shells.
#
class Shell
include Banner
include CommandKit::Printing
include CommandKit::Colors
#
# The default shell prompt name.
#
# @param [String, nil] new_name
# The optional new shell prompt name to set.
#
# @return [String]
# The shell prompt name.
#
def self.shell_name(new_name=nil)
if new_name
@shell_name = new_name
else
@shell_name ||= if superclass < Shell
superclass.shell_name
end
end
end
#
# The default prompt sigil.
#
# @param [String, nil] new_sigil
# The optional new prompt sigil to use.
#
# @return [String]
# The prompt sigil.
#
def self.prompt_sigil(new_sigil=nil)
if new_sigil
@prompt_sigil = new_sigil
else
@prompt_sigil ||= if superclass <= Shell
superclass.prompt_sigil
end
end
end
prompt_sigil '>'
#
# Starts the shell and processes each line of input.
#
# @param [Array