PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/termtter/optparse.rb

https://github.com/Epictetus/termtter
Ruby | 62 lines | 50 code | 12 blank | 0 comment | 1 complexity | 96ba2aebd64c5f95c8020e8e09acea7f MD5 | raw file
  1. module Termtter
  2. module OptParser
  3. class << self
  4. def parse!(argv)
  5. @optionparser.parse!(argv)
  6. end
  7. end
  8. @optionparser = OptionParser.new { |opt|
  9. opt.program_name = 'Termtter'
  10. opt.on('-f', '--config-file file', 'Set path to configfile') do |val|
  11. Termtter::CONF_FILE = val
  12. end
  13. opt.on('-t', '--termtter-directory directory', 'Set termtter directory') do |val|
  14. Termtter::CONF_DIR = val
  15. end
  16. opt.on('-d', '--devel', 'Start in developer mode') do |flg|
  17. config.__assign__(:devel, true) if flg
  18. end
  19. opt.on('-c', '--command-mode', 'Run as command mode') do |flg|
  20. config.system.cmd_mode = flg
  21. end
  22. opt.on('-r', '--run-command command', 'Run command') do |cmd|
  23. config.system.run_commands << cmd
  24. end
  25. opt.on('-p', '--plugin plugin', 'Load plugin') do |plugin|
  26. config.system.load_plugins << plugin
  27. end
  28. opt.on('-n', '--disable-plugin plugin', 'Disable plugin') do |plugin|
  29. config.system.disable_plugins << plugin
  30. end
  31. opt.on('-e', '--eval-script script', 'Eval script') do |script|
  32. config.system.eval_scripts << script
  33. end
  34. opt.on('-m', '--monochrome', 'No shell escapes for color highlightings') do |script|
  35. require 'termcolor'
  36. module ::TermColor
  37. class << self
  38. alias parse_orig parse
  39. def parse(o)
  40. o.gsub(/<\/?.+?>/, '').
  41. gsub('&lt;', '<').
  42. gsub('&gt;', '>')
  43. end
  44. end
  45. end
  46. end
  47. opt.version = Termtter::VERSION
  48. }
  49. end
  50. end