Skip to content

Commit

Permalink
Add simple completion method for readline
Browse files Browse the repository at this point in the history
  • Loading branch information
flori committed Aug 13, 2015
1 parent 10813cc commit eb31ff2
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Non yet.

## Changes

* 2015-08-13 Release 1.6.0
- Add complete method for readline completion
* 2015-06-21 Release 1.5.4
- Avoid %i syntax for now
* 2015-06-17 Release 1.5.3
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.4
1.6.0
1 change: 1 addition & 0 deletions lib/tins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ module Tins
if defined? ::Encoding
require 'tins/string_byte_order_mark'
end
require 'tins/complete'
end
require 'tins/alias'
18 changes: 18 additions & 0 deletions lib/tins/complete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'readline'

module Tins
module Complete
module_function

@@sync = Sync.new

def complete(prompt: '', add_hist: false, &block)
@@sync.synchronize do
Readline.completion_proc = block
Readline.input = STDIN
Readline.output = STDOUT
Readline.readline(prompt, add_hist)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/tins/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Tins
# Tins version
VERSION = '1.5.4'
VERSION = '1.6.0'
VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
Expand Down
1 change: 1 addition & 0 deletions lib/tins/xt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ module Tins
require 'tins/xt/time_freezer'
require 'tins/xt/case_predicate'
require 'tins/xt/implement'
require 'tins/xt/complete'
end
7 changes: 7 additions & 0 deletions lib/tins/xt/complete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'tins/complete'

module Tins
class ::Object
include Tins::Complete
end
end
10 changes: 5 additions & 5 deletions tins.gemspec

Large diffs are not rendered by default.

0 comments on commit eb31ff2

Please sign in to comment.