class RBT::Commandline

Public Class Methods

new( i = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/commandline/commandline.rb, line 40
def initialize(
    i           = ARGV,
    run_already = true
  )
  RBT.set_commandline_options(i) # ← Keep a reference to the commandline-options.
  reset
  run if run_already
end

Public Instance Methods

commandline_arguments?() click to toggle source
#

commandline_arguments?

#
# File lib/rbt/commandline/commandline.rb, line 70
def commandline_arguments?
  ::RBT.commandline_arguments?
end
create_new_cookbook_for(i) click to toggle source
#

create_new_cookbook_for

This method can create a new cookbook file - but only if the program has not yet been registered as part of RBT.

#
# File lib/rbt/commandline/commandline.rb, line 222
def create_new_cookbook_for(i)
  require 'rbt/cookbooks/create_cookbook_yaml_file/create_cookbook_yaml_file.rb'
  _ = RBT.remove_archive_from_the_end(File.basename(i))
  program_name = ProgramInformation.return_program_name(_)
  if RBT.is_a_registered_program? program_name
    e "The program #{program_name} is registered."
  else # else register it.
    e 'The program '+sfancy(program_name)+
      ' is not registered.'
    e 'Thus, delegating towards class '+
      steelblue('RBT::Cookbooks::CreateCookbookYamlFile')+
      '.'
    mkdir(src_dir?+program_name)
    RBT::Cookbooks::CreateCookbookYamlFile.new(i) { :interactive_mode }
  end
end
do_compile_these_programs( i = commandline_arguments? ) click to toggle source
#

do_compile_these_programs

This method can be used to compile

#
# File lib/rbt/commandline/commandline.rb, line 265
def do_compile_these_programs(
    i = commandline_arguments?
  )
  require 'rbt/requires/require_the_installer_class.rb'
  i = [i].flatten
  RBT::Installer.new(i)
end
menu( i = commandline_arguments? ) click to toggle source
#

menu

#
menu_for_the_commandline_arguments_as_string( i = commandline_arguments? ) click to toggle source
#

menu_for_the_commandline_arguments_as_string

This menu is specifically used to handle the full commandline argument.

#
require_class_compile() click to toggle source
#

require_class_compile

#
# File lib/rbt/commandline/commandline.rb, line 63
def require_class_compile
  require 'rbt/requires/require_the_installer_class.rb'
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/commandline/commandline.rb, line 52
def reset
  super()
  # ======================================================================= #
  # === @let_rbt_compile_handle_the_input
  # ======================================================================= #
  @let_rbt_compile_handle_the_input = false
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/commandline/commandline.rb, line 242
def run
  # ======================================================================= #
  # We will first pass all commandline arguments into menu() here,
  # before we typically then delegate towards class RBT::Installer.
  # ======================================================================= #
  menu_for_the_commandline_arguments_as_string
  if @let_rbt_compile_handle_the_input
    menu(commandline_arguments?)
  end
  # ======================================================================= #
  # And check it again.
  # ======================================================================= #
  if @let_rbt_compile_handle_the_input
    require_class_compile
    do_compile_these_programs(commandline_arguments?)
  end
end