Class: CodexLimitless::CLI
- Inherits:
-
Object
- Object
- CodexLimitless::CLI
- Defined in:
- lib/codex_limitless/cli.rb
Constant Summary collapse
- DEFAULT_PERCENTAGE =
15- AUTO_REFRESH_SECONDS =
60
Instance Method Summary collapse
-
#initialize(argv, out: $stdout, err: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv, out: $stdout, err: $stderr) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 18 19 |
# File 'lib/codex_limitless/cli.rb', line 14 def initialize(argv, out: $stdout, err: $stderr) @argv = argv.dup @out = out @err = err @status_line_width = 0 end |
Instance Method Details
#run ⇒ Object
21 22 23 24 25 26 27 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 |
# File 'lib/codex_limitless/cli.rb', line 21 def run = { codex_bin: ENV.fetch("CODEX_BIN", "codex"), limit_id: ENV.fetch("CODEX_LIMIT_ID", "codex"), percentage: DEFAULT_PERCENTAGE, command: nil } parser = option_parser() parser.parse!(@argv) case [:command] when :limits print_limits() when :wait wait_for_five_hour_reset() when :auto auto_wait_for_five_hour_reset() when :version @out.puts VERSION else @out.puts parser end 0 rescue OptionParser::ParseError => e @err.puts "Error: #{e.}" @err.puts @err.puts option_parser() 1 rescue StandardError => e @err.puts "Error: #{e.}" 1 end |