Class: HandleArgs
- Inherits:
-
Object
- Object
- HandleArgs
- Defined in:
- lib/handle_args.rb
Class Method Summary collapse
Class Method Details
.handle_args ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/handle_args.rb', line 28 def self.handle_args() p_args = HandleArgs.() ## This is the hash that will be returned. args_hash = {} ## This handles args then called as ruby script. ARGV.each_with_index do |arg, i| #Logging.log("Arg: #{arg}") if arg.start_with?('-') ## This is an option. if p_args.include?(arg) ## This is a permitted / available option. #Logging.log("Option: #{arg}") args_hash["option_#{i}"] = arg else ## This is an unknown option. ## TODO: Handle unknown option. display help? discard? Logging.log("Unknown option: #{arg}") args_hash["option_#{i}"] = arg end else ## This is input. ## This if statement append all 'input' args to one string. if args_hash["input"].nil? args_hash["input"] = arg else args_hash["input"] = "#{args_hash['input']} #{arg}" end end end return args_hash end |
.permitted_options ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/handle_args.rb', line 2 def self.() ## TODO: Add more options. ## -t --translate ## -temp --temperature (need to handle value after input) [ '-h', '--help', '-v', '--version', '-f', '--file', '-lf', '--loadfile', '-d', '--delete', '-c', '--conversation', '--finetune', '-w', '--whisper', '-t', '--translate', '-i', '--interactive', '--key', ] end |