Class: Lutaml::Cli::InteractiveShell::HelpDisplay

Inherits:
CommandBase
  • Object
show all
Defined in:
lib/lutaml/cli/interactive_shell/help_display.rb

Constant Summary collapse

HELP_TEXT =
<<~HELP
  Available Commands:

  Navigation:
    cd PATH           Change to package path
    pwd               Print current path
    ls [PATH]         List packages
    tree [PATH]       Show package tree
    up                Go to parent package
    root              Go to ModelRoot
    back              Go to previous location

  Query:
    find CLASS        Find class (fuzzy search)
    show class QNAME  Show class details
    show package PATH Show package details
    show NUMBER       Show numbered result
    search QUERY      Full-text search
    ? QUERY           Alias for search

  Bookmarks:
    bookmark add NAME  Bookmark current location
    bookmark list      List bookmarks
    bookmark go NAME   Jump to bookmark
    bookmark rm NAME   Remove bookmark
    bm NAME            Quick jump

  Utilities:
    help [COMMAND]    Show help
    history           Show command history
    clear             Clear screen
    config            Show configuration
    stats             Show statistics
    exit, quit, q     Exit shell
HELP

Instance Attribute Summary

Attributes inherited from CommandBase

#shell

Instance Method Summary collapse

Methods inherited from CommandBase

#bookmarks, #config, #current_path, #current_path=, #initialize, #last_results, #last_results=, #path_history, #repository

Constructor Details

This class inherits a constructor from Lutaml::Cli::InteractiveShell::CommandBase

Instance Method Details

#cmd_clear(_args) ⇒ Object



42
43
44
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 42

def cmd_clear(_args)
  print "\e[2J\e[H"
end

#cmd_config(_args) ⇒ Object



46
47
48
49
50
51
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 46

def cmd_config(_args)
  puts OutputFormatter.colorize("Current Configuration:", :cyan)
  config.each do |key, value|
    puts "  #{key}: #{value}"
  end
end

#cmd_help(args) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 27

def cmd_help(args)
  if args.empty?
    display_general_help
  else
    display_command_help(args[0])
  end
end

#cmd_history(_args) ⇒ Object



35
36
37
38
39
40
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 35

def cmd_history(_args)
  history = Readline::HISTORY.to_a.last(20)
  history.each_with_index do |line, i|
    puts "#{i + 1}. #{line}"
  end
end

#cmd_stats(_args) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 53

def cmd_stats(_args)
  stats = repository.statistics

  if config[:icons]
    puts EnhancedFormatter.format_stats_enhanced(stats)
  else
    puts OutputFormatter.format_stats(stats, detailed: false)
  end
end

#display_command_help(command) ⇒ Object



103
104
105
106
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 103

def display_command_help(command)
  puts "Help for '#{command}' not yet implemented"
  puts "Use 'help' for general help"
end

#display_general_helpObject



99
100
101
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 99

def display_general_help
  puts OutputFormatter.colorize(HELP_TEXT, :cyan)
end

#display_welcomeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lutaml/cli/interactive_shell/help_display.rb', line 10

def display_welcome
  puts <<~WELCOME
    #{OutputFormatter.colorize('╔═══════════════════════════════════════╗', :cyan)}
    #{OutputFormatter.colorize('║  LutaML Interactive Shell (REPL)     ║', :cyan)}
    #{OutputFormatter.colorize('╚═══════════════════════════════════════╝', :cyan)}

    Type 'help' for available commands, 'exit' to quit

  WELCOME

  stats = repository.statistics
  puts "Repository loaded:"
  puts "  #{stats[:total_packages]} packages, " \
       "#{stats[:total_classes]} classes"
  puts ""
end