Class: Askcii::CLI
- Inherits:
-
Object
- Object
- Askcii::CLI
- Defined in:
- lib/askcii/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
Instance Method Summary collapse
- #clear_history? ⇒ Boolean
- #configure? ⇒ Boolean
- #help? ⇒ Boolean
- #help_message ⇒ Object
- #history? ⇒ Boolean
-
#initialize(args = ARGV.dup) ⇒ CLI
constructor
A new instance of CLI.
- #last_response? ⇒ Boolean
- #list_sessions? ⇒ Boolean
- #model_config_id ⇒ Object
- #parse! ⇒ Object
- #private? ⇒ Boolean
- #session ⇒ Object
- #show_help? ⇒ Boolean
- #show_usage? ⇒ Boolean
- #usage_message ⇒ Object
- #verbose? ⇒ Boolean
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 = {} @prompt = nil end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/askcii/cli.rb', line 7 def end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
7 8 9 |
# File 'lib/askcii/cli.rb', line 7 def prompt @prompt end |
Instance Method Details
#clear_history? ⇒ Boolean
65 66 67 |
# File 'lib/askcii/cli.rb', line 65 def clear_history? [:clear_history] end |
#configure? ⇒ Boolean
33 34 35 |
# File 'lib/askcii/cli.rb', line 33 def configure? [:configure] end |
#help? ⇒ Boolean
29 30 31 |
# File 'lib/askcii/cli.rb', line 29 def help? [:help] end |
#help_message ⇒ Object
69 70 71 |
# File 'lib/askcii/cli.rb', line 69 def option_parser.to_s end |
#history? ⇒ Boolean
61 62 63 |
# File 'lib/askcii/cli.rb', line 61 def history? [:history] end |
#last_response? ⇒ Boolean
37 38 39 |
# File 'lib/askcii/cli.rb', line 37 def last_response? [:last_response] end |
#list_sessions? ⇒ Boolean
57 58 59 |
# File 'lib/askcii/cli.rb', line 57 def list_sessions? [:list_sessions] end |
#model_config_id ⇒ Object
49 50 51 |
# File 'lib/askcii/cli.rb', line 49 def model_config_id [: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
41 42 43 |
# File 'lib/askcii/cli.rb', line 41 def private? [:private] end |
#session ⇒ Object
53 54 55 |
# File 'lib/askcii/cli.rb', line 53 def session [:session] end |
#show_help? ⇒ Boolean
21 22 23 |
# File 'lib/askcii/cli.rb', line 21 def show_help? [:help] end |
#show_usage? ⇒ Boolean
25 26 27 |
# File 'lib/askcii/cli.rb', line 25 def show_usage? @prompt.empty? && !configure? && !last_response? && !list_sessions? && !history? && !clear_history? end |
#usage_message ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/askcii/cli.rb', line 73 def " Usage:\n askcii [options] 'Your prompt here'\n echo 'Your prompt here' | askcii # Use piped text as prompt\n echo 'Context text' | askcii 'Your prompt here' # Use piped text as context\n askcii 'Your prompt here' < prompt.txt # Use file content as context\n cat prompt.txt | askcii # Use file content as prompt\n askcii -p (start a private session)\n askcii -r (to get the last response)\n askcii -c (manage configurations)\n askcii -m 2 (use configuration ID 2)\n\n Options:\n -p, --private Start a private session and do not record\n -r, --last-response Output the last response\n -c, --configure Manage configurations\n -m, --model ID Use specific configuration ID\n -h, --help Show help\n USAGE\nend\n" |
#verbose? ⇒ Boolean
45 46 47 |
# File 'lib/askcii/cli.rb', line 45 def verbose? [:verbose] end |