Class: Askcii::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/askcii/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = ARGV.dup) ⇒ CLI

Returns a new instance of CLI.



9
10
11
12
13
# File 'lib/askcii/cli.rb', line 9

def initialize(args = ARGV.dup)
  @args = args
  @options = {}
  @prompt = nil
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/askcii/cli.rb', line 7

def options
  @options
end

#promptObject (readonly)

Returns the value of attribute prompt.



7
8
9
# File 'lib/askcii/cli.rb', line 7

def prompt
  @prompt
end

Instance Method Details

#configure?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/askcii/cli.rb', line 29

def configure?
  @options[:configure]
end

#help_messageObject



45
46
47
# File 'lib/askcii/cli.rb', line 45

def help_message
  option_parser.to_s
end

#last_response?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/askcii/cli.rb', line 33

def last_response?
  @options[:last_response]
end

#model_config_idObject



41
42
43
# File 'lib/askcii/cli.rb', line 41

def model_config_id
  @options[:model_config_id]
end

#parse!Object



15
16
17
18
19
# File 'lib/askcii/cli.rb', line 15

def parse!
  option_parser.parse!(@args)
  @prompt = @args.join(' ')
  self
end

#private?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/askcii/cli.rb', line 37

def private?
  @options[:private]
end

#show_help?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/askcii/cli.rb', line 21

def show_help?
  @options[:help]
end

#show_usage?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/askcii/cli.rb', line 25

def show_usage?
  false # Usage logic is now handled in Application class
end

#usage_messageObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/askcii/cli.rb', line 49

def usage_message
  <<~USAGE
    Usage:
      askcii [options] 'Your prompt here'
      echo 'Your prompt here' | askcii                    # Use piped text as prompt
      echo 'Context text' | askcii 'Your prompt here'     # Use piped text as context
      askcii 'Your prompt here' < prompt.txt              # Use file content as context
      cat prompt.txt | askcii                             # Use file content as prompt
      askcii -p (start a private session)
      askcii -r (to get the last response)
      askcii -c (manage configurations)
      askcii -m 2 (use configuration ID 2)

    Options:
      -p, --private         Start a private session and do not record
      -r, --last-response   Output the last response
      -c, --configure       Manage configurations
      -m, --model ID        Use specific configuration ID
      -h, --help            Show help
  USAGE
end