Class: RubynCode::CLI::Commands::Learning

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/learning.rb

Overview

‘/learning` — inspect and move the instincts Rubyn learns across sessions. Continuous learning runs automatically at the end of each session; this command lets you carry those learnings to another machine.

/learning                       show learning stats
/learning export [path]         export all instincts to a JSON file
/learning import <path> [--here] import instincts (--here = remap to this project)

Constant Summary collapse

DEFAULT_FILE =
'rubyn-learnings.json'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases, all_names, hidden?

Class Method Details

.command_nameObject



14
# File 'lib/rubyn_code/cli/commands/learning.rb', line 14

def self.command_name = '/learning'

.descriptionObject



15
# File 'lib/rubyn_code/cli/commands/learning.rb', line 15

def self.description  = 'Show, export, or import learned instincts (/learning export|import)'

Instance Method Details

#execute(args, ctx) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rubyn_code/cli/commands/learning.rb', line 19

def execute(args, ctx)
  case args.first
  when 'export' then export(ctx, args[1])
  when 'import' then import(ctx, args[1..])
  when nil      then stats(ctx)
  else
    ctx.renderer.info('Usage: /learning [export [path] | import <path> [--here]]')
  end
  nil
rescue RubynCode::Learning::Porter::Error => e
  ctx.renderer.error("Learning: #{e.message}")
  nil
end