Class: RubynCode::CLI::Commands::Resume

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

Overview

List saved sessions or restore one into the current conversation.

/resume                # list sessions, recent first
/resume <id>           # load session <id> (prompts before clobber)
/resume <id> --force   # skip the confirm prompt

Constant Summary collapse

MAX_LIST_ENTRIES =
10

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/resume.rb', line 14

def self.command_name = '/resume'

.descriptionObject



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

def self.description = 'List saved sessions or restore one into the current conversation'

Instance Method Details

#execute(args, ctx) ⇒ Object



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

def execute(args, ctx)
  persistence = ctx.session_persistence
  if persistence.nil?
    ctx.renderer.error('No session persistence wired in. Run a prompt first.')
    return
  end

  opts = parse_args(args)

  if opts[:id].nil?
    list_sessions(persistence, ctx)
    return
  end

  restore_session(persistence, opts, ctx)
end