Class: Chronolog::CLI
- Inherits:
-
Object
- Object
- Chronolog::CLI
- Defined in:
- lib/chronolog/cli.rb
Constant Summary collapse
- CLI_CMDS =
%w[quit help].freeze
- LIB_CMDS =
%w[print start started stop stopped].freeze
- CMDS =
(CLI_CMDS + LIB_CMDS).sort.freeze
Instance Method Summary collapse
-
#initialize(path) ⇒ CLI
constructor
A new instance of CLI.
- #run(cmd) ⇒ Object
Constructor Details
Instance Method Details
#run(cmd) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chronolog/cli.rb', line 15 def run(cmd) if cmd.empty? @interactive = true comp = proc { |s| CMDS.grep(/^#{Regexp.escape(s)}/) } Readline.completion_append_character = "" Readline.completion_proc = comp exec(cmd) while (cmd = Readline.readline("> ", true)) else exec(cmd) end rescue Interrupt exit end |