Class: Lutaml::Cli::InteractiveShell::BookmarkCommands
- Inherits:
-
CommandBase
- Object
- CommandBase
- Lutaml::Cli::InteractiveShell::BookmarkCommands
show all
- Defined in:
- lib/lutaml/cli/interactive_shell/bookmark_commands.rb
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
Instance Method Details
#bookmark_add(name) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/lutaml/cli/interactive_shell/bookmark_commands.rb', line 29
def bookmark_add(name)
if name.nil? || name.empty?
puts OutputFormatter.warning("Usage: bookmark add NAME")
return
end
target = last_results&.first || current_path
bookmarks[name] = target
puts OutputFormatter.success("Bookmark '#{name}' added: #{target}")
end
|
#bookmark_go(name) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/lutaml/cli/interactive_shell/bookmark_commands.rb', line 52
def bookmark_go(name)
unless bookmarks.key?(name)
puts OutputFormatter.error("Bookmark not found: #{name}")
return
end
target = bookmarks[name]
if repository.find_package(target)
push_path_history
self.current_path = target
puts "Changed to: #{target}"
else
puts OutputFormatter.warning(
"Bookmark target no longer exists: #{target}",
)
end
end
|
#bookmark_list ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/lutaml/cli/interactive_shell/bookmark_commands.rb', line 40
def bookmark_list
if bookmarks.empty?
puts "No bookmarks"
else
puts OutputFormatter.colorize("Bookmarks:", :cyan)
bookmarks.each do |name, target|
icon = config[:icons] ? "#{EnhancedFormatter::ICONS[:favorite]} " : ""
puts " #{icon}#{name} → #{target}"
end
end
end
|
#bookmark_remove(name) ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/lutaml/cli/interactive_shell/bookmark_commands.rb', line 70
def bookmark_remove(name)
if bookmarks.delete(name)
puts OutputFormatter.success("Bookmark '#{name}' removed")
else
puts OutputFormatter.error("Bookmark not found: #{name}")
end
end
|
#cmd_bookmark(args) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/lutaml/cli/interactive_shell/bookmark_commands.rb', line 10
def cmd_bookmark(args)
return bookmark_list if args.empty?
subcommand = args[0].downcase
case subcommand
when "add"
bookmark_add(args[1])
when "list"
bookmark_list
when "go"
bookmark_go(args[1])
when "rm", "remove"
bookmark_remove(args[1])
else
bookmark_go(subcommand)
end
end
|