mkalias 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mkalias +34 -15
- data/lib/mkalias/version.rb +1 -1
- data/lib/mkalias.rb +29 -2
- 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: 069677b180ab50f66ae2ddf82ad06b69e668a829
|
4
|
+
data.tar.gz: b349857319e75e075572053630e6438c6e02e9a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a601e27c7c47b5764721d60169e24715246fa88caacd2085842db0db6fa673c975baba53daab9b12287e8a70a3218565951da00e014a0c0f329b74cf22d9f4e9
|
7
|
+
data.tar.gz: e8330f81d6fe54b6445aca204cc7b84746958f34861578f225b700bea5e9593ef0921a2da81adbbb220c97af05066e96dd6288e20dbaf0340d7f58c762c66ba1
|
data/bin/mkalias
CHANGED
@@ -47,18 +47,28 @@ end
|
|
47
47
|
|
48
48
|
def show_alias
|
49
49
|
if ARGV.count < 2
|
50
|
-
|
50
|
+
alias_names = Mkalias.list_alias
|
51
|
+
else
|
52
|
+
alias_names = ARGV[1..-1]
|
51
53
|
end
|
52
|
-
|
53
|
-
|
54
|
+
commands = Mkalias.show_alias(alias_names)
|
55
|
+
|
56
|
+
alias_not_founded = alias_names - commands.keys
|
57
|
+
unless alias_not_founded.empty?
|
58
|
+
alias_not_founded = alias_not_founded.join(', ')
|
59
|
+
puts "Alias not founded: #{alias_not_founded}"
|
60
|
+
puts ""
|
61
|
+
end
|
62
|
+
|
63
|
+
unless commands.empty?
|
64
|
+
commands.each do |alias_name, alias_functions|
|
65
|
+
puts "- #{alias_name}"
|
54
66
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
67
|
+
alias_functions.each do |alias_function|
|
68
|
+
puts " #{alias_function}"
|
69
|
+
puts ""
|
70
|
+
end
|
59
71
|
end
|
60
|
-
else
|
61
|
-
puts "Alias [#{alias_name}] not founded"
|
62
72
|
end
|
63
73
|
end
|
64
74
|
|
@@ -66,13 +76,22 @@ def remove_alias
|
|
66
76
|
if ARGV.count < 2
|
67
77
|
usage
|
68
78
|
end
|
69
|
-
|
70
|
-
|
79
|
+
alias_names = ARGV[1..-1]
|
80
|
+
removed_alias = Mkalias.remove_alias(alias_names)
|
81
|
+
|
82
|
+
alias_not_founded = alias_names - removed_alias
|
83
|
+
unless alias_not_founded.empty?
|
84
|
+
alias_not_founded = alias_not_founded.join(', ')
|
85
|
+
puts "Alias not founded: #{alias_not_founded}"
|
86
|
+
puts ""
|
87
|
+
end
|
71
88
|
|
72
|
-
|
73
|
-
puts "Removed Alias:
|
74
|
-
|
75
|
-
|
89
|
+
unless removed_alias.empty?
|
90
|
+
puts "Removed Alias:"
|
91
|
+
|
92
|
+
removed_alias.each do |alias_name|
|
93
|
+
puts "- #{alias_name}"
|
94
|
+
end
|
76
95
|
end
|
77
96
|
end
|
78
97
|
|
data/lib/mkalias/version.rb
CHANGED
data/lib/mkalias.rb
CHANGED
@@ -39,7 +39,34 @@ module Mkalias
|
|
39
39
|
alias_names.to_a
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.show_alias(
|
42
|
+
def self.show_alias(alias_names, file_path=BASHRC_PATH)
|
43
|
+
alias_names = [alias_names] unless alias_names.kind_of?(Array)
|
44
|
+
|
45
|
+
alias_functions = {}
|
46
|
+
alias_names.each do |alias_name|
|
47
|
+
alias_functions[alias_name] = Mkalias.get_alias_function(alias_name,
|
48
|
+
file_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_functions.select!{ |key, value| !value.nil? }
|
52
|
+
return alias_functions
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.remove_alias(alias_names, file_path=BASHRC_PATH)
|
56
|
+
alias_names = [alias_names] unless alias_names.kind_of?(Array)
|
57
|
+
|
58
|
+
removed_alias = []
|
59
|
+
alias_names.each do |alias_name|
|
60
|
+
removed = Mkalias.remove_one_alias(alias_name, file_path)
|
61
|
+
removed_alias << alias_name if removed
|
62
|
+
end
|
63
|
+
|
64
|
+
return removed_alias
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def self.get_alias_function(alias_name, file_path=BASHRC_PATH)
|
43
70
|
alias_names = Mkalias.list_alias(file_path)
|
44
71
|
return nil unless alias_names.include?(alias_name)
|
45
72
|
|
@@ -56,7 +83,7 @@ module Mkalias
|
|
56
83
|
nil
|
57
84
|
end
|
58
85
|
|
59
|
-
def self.
|
86
|
+
def self.remove_one_alias(alias_name, file_path=BASHRC_PATH)
|
60
87
|
alias_names = Mkalias.list_alias(file_path)
|
61
88
|
return false unless alias_names.include?(alias_name)
|
62
89
|
|