Class: RosettAi::Thor::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/cli.rb

Overview

Main CLI entry point for Rosett-AI commands

Constant Summary collapse

INTERNAL_COMMANDS =
['build', 'release', 'documentation', 'dbus', 'desktop'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rosett_ai/thor/cli.rb', line 15

def self.exit_on_failure?
  true
end

.printable_commands(all = true, subcommand = false) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter -- matches Thor's API



20
21
22
23
24
25
26
27
28
29
# File 'lib/rosett_ai/thor/cli.rb', line 20

def self.printable_commands(all = true, subcommand = false)
  # rubocop:enable Style/OptionalBooleanParameter
  cmds = super
  return cmds if RosettAi.context.rai_internal?

  cmds.reject do |row|
    words = row.first.split
    INTERNAL_COMMANDS.include?(words[1])
  end
end

Instance Method Details

#treeObject



198
199
200
201
202
# File 'lib/rosett_ai/thor/cli.rb', line 198

def tree
  say 'rai', :blue
  leaves, groups = tree_partition_entries(self.class)
  tree_render_entries(leaves, groups, '  ')
end

#versionObject



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rosett_ai/thor/cli.rb', line 92

def version
  puts ::I18n.t('rosett_ai.cli.version', version: RosettAi::VERSION)
  build_info = RosettAi.root.join('..', 'etc', 'BUILD_INFO')
  return unless build_info.exist?

  info = parse_build_info(build_info)
  puts "  commit:  #{info['commit']}" if info['commit']
  puts "  branch:  #{info['branch']}" if info['branch']
  puts "  built:   #{info['build_date']}" if info['build_date']
  puts "  variant: #{info['variant']}" if info['variant']
end