Class: Lutaml::Cli::InteractiveShell

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/cli/interactive_shell.rb,
lib/lutaml/cli/interactive_shell/command_base.rb,
lib/lutaml/cli/interactive_shell/help_display.rb,
lib/lutaml/cli/interactive_shell/export_handler.rb,
lib/lutaml/cli/interactive_shell/query_commands.rb,
lib/lutaml/cli/interactive_shell/bookmark_commands.rb,
lib/lutaml/cli/interactive_shell/navigation_commands.rb

Defined Under Namespace

Classes: BookmarkCommands, CommandBase, ExportHandler, HelpDisplay, NavigationCommands, QueryCommands

Constant Summary collapse

HISTORY_FILE =
File.expand_path("~/.lutaml-xmi-history")
MAX_HISTORY =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lur_path_or_repo, config: nil) ⇒ InteractiveShell

Returns a new instance of InteractiveShell.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lutaml/cli/interactive_shell.rb', line 26

def initialize(lur_path_or_repo, config: nil)
  @config = default_config.merge(config || {})
  @repository = load_repository(lur_path_or_repo)

  @current_path = "ModelRoot"
  @bookmarks = {}
  @last_results = nil
  @path_history = ["ModelRoot"]
  @running = false

  init_commands
  setup_readline
  load_history
end

Instance Attribute Details

#bookmarksObject (readonly)

Returns the value of attribute bookmarks.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def bookmarks
  @bookmarks
end

#bookmarks_cmdObject (readonly)

Returns the value of attribute bookmarks_cmd.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def bookmarks_cmd
  @bookmarks_cmd
end

#configObject (readonly)

Returns the value of attribute config.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def config
  @config
end

#current_pathObject

Returns the value of attribute current_path.



24
25
26
# File 'lib/lutaml/cli/interactive_shell.rb', line 24

def current_path
  @current_path
end

#exportObject (readonly)

Returns the value of attribute export.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def export
  @export
end

#helpObject (readonly)

Returns the value of attribute help.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def help
  @help
end

#last_resultsObject

Returns the value of attribute last_results.



24
25
26
# File 'lib/lutaml/cli/interactive_shell.rb', line 24

def last_results
  @last_results
end

Returns the value of attribute navigation.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def navigation
  @navigation
end

#path_historyObject (readonly)

Returns the value of attribute path_history.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def path_history
  @path_history
end

#queryObject (readonly)

Returns the value of attribute query.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def query
  @query
end

#repositoryObject (readonly)

Returns the value of attribute repository.



20
21
22
# File 'lib/lutaml/cli/interactive_shell.rb', line 20

def repository
  @repository
end

Instance Method Details

#startObject



41
42
43
44
45
46
47
48
49
# File 'lib/lutaml/cli/interactive_shell.rb', line 41

def start
  @running = true
  @help.display_welcome

  run_repl_loop

  save_history
  puts "\nGoodbye!"
end