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
- #configure? ⇒ Boolean
- #help_message ⇒ Object
-
#initialize(args = ARGV.dup) ⇒ CLI
constructor
A new instance of CLI.
- #last_response? ⇒ Boolean
- #model_config_id ⇒ Object
- #parse! ⇒ Object
- #private? ⇒ Boolean
- #show_help? ⇒ Boolean
- #show_usage? ⇒ Boolean
- #usage_message ⇒ Object
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
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/askcii/cli.rb', line 7 def @options 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
#configure? ⇒ Boolean
29 30 31 |
# File 'lib/askcii/cli.rb', line 29 def configure? @options[:configure] end |
#help_message ⇒ Object
45 46 47 |
# File 'lib/askcii/cli.rb', line 45 def option_parser.to_s end |
#last_response? ⇒ Boolean
33 34 35 |
# File 'lib/askcii/cli.rb', line 33 def last_response? @options[:last_response] end |
#model_config_id ⇒ Object
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
37 38 39 |
# File 'lib/askcii/cli.rb', line 37 def private? @options[:private] end |
#show_help? ⇒ Boolean
21 22 23 |
# File 'lib/askcii/cli.rb', line 21 def show_help? @options[:help] end |
#show_usage? ⇒ 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_message ⇒ Object
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 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 |