prompt 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/lib/prompt/application.rb +4 -4
- data/lib/prompt/console/console_module.rb +20 -3
- data/lib/prompt/prompt_module.rb +1 -1
- metadata +5 -5
data/CHANGELOG.md
CHANGED
data/lib/prompt/application.rb
CHANGED
@@ -38,6 +38,10 @@ module Prompt
|
|
38
38
|
all_completions(args[0,last_idx], word_starting_with)
|
39
39
|
end
|
40
40
|
|
41
|
+
def commands
|
42
|
+
@command_groups.map(&:commands).flatten(1)
|
43
|
+
end
|
44
|
+
|
41
45
|
private
|
42
46
|
|
43
47
|
def index_of_last_word line
|
@@ -54,10 +58,6 @@ module Prompt
|
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
57
|
-
def commands
|
58
|
-
@command_groups.map(&:commands).flatten(1)
|
59
|
-
end
|
60
|
-
|
61
61
|
def all_completions(args, partial_arg)
|
62
62
|
commands.select { |c| c.could_match? args }.map do |c|
|
63
63
|
c.completions(args.length, partial_arg)
|
@@ -15,13 +15,17 @@ module Prompt
|
|
15
15
|
def self.start(history_file = nil)
|
16
16
|
# Store the state of the terminal
|
17
17
|
stty_save = `stty -g`.chomp
|
18
|
-
# and restore it when exiting
|
18
|
+
# ...and restore it when exiting
|
19
19
|
at_exit do
|
20
20
|
system('stty', stty_save)
|
21
21
|
save_history history_file if history_file
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
# Exit immediately on Ctrl-C
|
25
|
+
trap('INT') do
|
26
|
+
puts
|
27
|
+
exit
|
28
|
+
end
|
25
29
|
|
26
30
|
Readline.completion_proc = CompletionProc
|
27
31
|
|
@@ -33,7 +37,7 @@ module Prompt
|
|
33
37
|
next if words == []
|
34
38
|
Prompt.application.exec words
|
35
39
|
rescue CommandNotFound
|
36
|
-
|
40
|
+
command_not_found line
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
@@ -55,6 +59,19 @@ module Prompt
|
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
62
|
+
def self.command_not_found line
|
63
|
+
words = self.split line
|
64
|
+
suggestions = Prompt.application.commands.select { |cmd| cmd.could_match? words }
|
65
|
+
if suggestions.empty?
|
66
|
+
puts "Command not found"
|
67
|
+
else
|
68
|
+
puts "Command not found. Did you mean one of these?"
|
69
|
+
suggestions.each do |cmd|
|
70
|
+
puts " #{cmd.usage}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
58
75
|
private
|
59
76
|
|
60
77
|
S_QUOTED_ARG = /'([^']*)'/
|
data/lib/prompt/prompt_module.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prompt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: Prompt makes it easy to build slick command-line applications with
|
15
|
-
|
14
|
+
description: Prompt makes it easy to build slick command-line applications with tab
|
15
|
+
completion, command history, and built-in help
|
16
16
|
email: mike@sticknet.net
|
17
17
|
executables: []
|
18
18
|
extensions: []
|
@@ -64,5 +64,5 @@ rubyforge_project:
|
|
64
64
|
rubygems_version: 1.8.11
|
65
65
|
signing_key:
|
66
66
|
specification_version: 3
|
67
|
-
summary: A
|
67
|
+
summary: A micro framework that makes it easy to build slick command-line applications
|
68
68
|
test_files: []
|