am 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -8
- data/lib/am/cli.rb +4 -6
- data/lib/am/version.rb +1 -1
- data/lib/message_control.rb +2 -2
- data/lib/ui.rb +6 -9
- data/spec/spec_helper.rb +2 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 607457b961dba43878566b3a4bb32f656a4d3993
|
4
|
+
data.tar.gz: 04e5f824a7374a4f9569255ae44b853a8c2032b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c78383e7b482182f52c12e265d083c16d6255305f22d587a4b33fcb68d0205e7f870f1529afcb1f8a3530fbfe91e38da6343c162ae998b0e00a17c42c7d9de5
|
7
|
+
data.tar.gz: e58d5542d42370b85ece05fc01b8d54ecc9fdb6f1e49bc8e5751c8ee72d33b4510dbb168edeffb3ff29fd6682a3f417cb2c51ec602bba74a36b7acb78eb7b154
|
data/README.md
CHANGED
@@ -44,15 +44,9 @@ echo 'source ~/.am_config' >> ~/.bash_profile
|
|
44
44
|
print current config
|
45
45
|
|
46
46
|
$ am add
|
47
|
-
add alias
|
47
|
+
add alias select last history command
|
48
48
|
|
49
|
-
$ am
|
50
|
-
add alias select from five line last history command
|
51
|
-
|
52
|
-
$ am del [alias_name)
|
53
|
-
delete alias from alias_name
|
54
|
-
|
55
|
-
$ am del -l(list)
|
49
|
+
$ am del
|
56
50
|
delete alias select from current config
|
57
51
|
|
58
52
|
### configure
|
data/lib/am/cli.rb
CHANGED
@@ -39,7 +39,7 @@ module AM
|
|
39
39
|
@ui.print_last_commands(commands)
|
40
40
|
new_alias = @ui.add_command_with_number(commands)
|
41
41
|
|
42
|
-
unless new_alias
|
42
|
+
unless Hash.try_convert(new_alias)
|
43
43
|
add
|
44
44
|
else
|
45
45
|
if uniq?(new_alias)
|
@@ -51,14 +51,12 @@ module AM
|
|
51
51
|
desc "del", "delete alias"
|
52
52
|
def del
|
53
53
|
unless @config.al.empty?
|
54
|
-
|
55
|
-
delete_alias = @ui.
|
56
|
-
|
57
|
-
if delete_alias && @config.al.key?(delete_alias)
|
54
|
+
@ui.print_current_config(@config)
|
55
|
+
delete_alias = @ui.delete_command_with_number(@config)
|
56
|
+
unless delete_alias.nil?
|
58
57
|
@config.al.delete(delete_alias)
|
59
58
|
@config.delete_config(delete_alias)
|
60
59
|
else
|
61
|
-
warning(:empty_config_number)
|
62
60
|
del
|
63
61
|
end
|
64
62
|
else
|
data/lib/am/version.rb
CHANGED
data/lib/message_control.rb
CHANGED
data/lib/ui.rb
CHANGED
@@ -10,23 +10,18 @@ module AM
|
|
10
10
|
def print_current_config(config)
|
11
11
|
aml = config.al.max_by{|c| c[0].length }[0].length #alias max length
|
12
12
|
iml = config.al.length.to_s.length #index max length
|
13
|
-
arr = [] #use delete number
|
14
13
|
|
15
|
-
before_sepalate
|
16
14
|
puts 'current registered alias'
|
17
15
|
config.al.each_with_index do|(k,v),i|
|
18
16
|
# 1: name=command
|
19
17
|
puts " #{' '*(iml - (i+1).to_s.length)}#{(i+1).to_s} : #{k.to_s}#{' '*(aml-k.length)} = #{v.to_s}"
|
20
|
-
arr << [i,k]
|
21
18
|
end
|
22
19
|
after_sepalate
|
23
|
-
arr
|
24
20
|
end
|
25
21
|
|
26
22
|
def print_last_commands(commands)
|
27
23
|
iml = commands.length.to_s.length #index max length
|
28
24
|
|
29
|
-
before_sepalate
|
30
25
|
puts 'current history commands'
|
31
26
|
commands.each_with_index do |c,i|
|
32
27
|
puts " #{' '*(iml - (i+1).to_s.length)}#{(i+1).to_s} : #{c.to_s}"
|
@@ -45,14 +40,16 @@ module AM
|
|
45
40
|
alias_name = get_alias
|
46
41
|
{alias_name => quot(commands[number.to_i-1].strip)}
|
47
42
|
end
|
48
|
-
|
49
43
|
end
|
50
44
|
|
51
|
-
def
|
45
|
+
def delete_command_with_number(config)
|
52
46
|
number = get_number
|
53
|
-
|
54
47
|
if valid?(number, "^[1-9]+$")
|
55
|
-
|
48
|
+
if config.al.length >= number.to_i && config.al.key?(config.al.to_a[number.to_i-1][0])
|
49
|
+
config.al.to_a[number.to_i-1][0]
|
50
|
+
else
|
51
|
+
warning(:empty_config_number)
|
52
|
+
end
|
56
53
|
else
|
57
54
|
warning(:validate_number)
|
58
55
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -47,15 +47,13 @@ end
|
|
47
47
|
|
48
48
|
def match_current_config
|
49
49
|
return <<'EOS'
|
50
|
-
|
51
|
-
------------------------------------------------------------
|
52
50
|
current registered alias
|
53
51
|
1 : hoge = 'fuga'
|
54
52
|
2 : 123 = '123'
|
55
53
|
3 : ABC = 'ABC'
|
56
54
|
4 : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
57
55
|
5 : ほげ = 'ふがふが'
|
58
|
-
|
56
|
+
============================================================
|
59
57
|
|
60
58
|
EOS
|
61
59
|
end
|
@@ -77,15 +75,13 @@ end
|
|
77
75
|
|
78
76
|
def match_delete_list
|
79
77
|
return <<'EOS'
|
80
|
-
|
81
|
-
------------------------------------------------------------
|
82
78
|
current registered alias
|
83
79
|
1 : hoge = 'fuga'
|
84
80
|
2 : 123 = '123'
|
85
81
|
3 : ABC = 'ABC'
|
86
82
|
4 : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
|
87
83
|
5 : ほげ = 'ふがふが'
|
88
|
-
|
84
|
+
============================================================
|
89
85
|
|
90
86
|
EOS
|
91
87
|
end
|