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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd47bd35f7cb160d4a209838e9a0384ea081b42b
4
- data.tar.gz: ad7ce8f2afec654354550b80437a8c715386fa33
3
+ metadata.gz: 069677b180ab50f66ae2ddf82ad06b69e668a829
4
+ data.tar.gz: b349857319e75e075572053630e6438c6e02e9a7
5
5
  SHA512:
6
- metadata.gz: 57a71e1af1262c429768fa950e721ef47a8ad6fb0380208a2934885a49a277f3613a9a491bd6fae408741ebbcafaad49d98ce51d0709bb41cb607841f0a49cfe
7
- data.tar.gz: eafc43c7abc1dbf76afed820ae5acdabbd6d0bb2a24319f89e09dd5f57289da9196078f4713546d7a51344f5e4205e3aac46b6b8a57cce58fc18fe4a8af1a134
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
- usage
50
+ alias_names = Mkalias.list_alias
51
+ else
52
+ alias_names = ARGV[1..-1]
51
53
  end
52
- alias_name = ARGV[1]
53
- commands = Mkalias.show_alias(alias_name)
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
- if commands
56
- puts "#{alias_name}:"
57
- commands.each do |command|
58
- puts " #{command}"
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
- alias_name = ARGV[1]
70
- removed = Mkalias.remove_alias(alias_name)
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
- if removed
73
- puts "Removed Alias: #{alias_name}"
74
- else
75
- puts "Alias [#{alias_name}] not founded"
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
 
@@ -1,3 +1,3 @@
1
1
  module Mkalias
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
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(alias_name, file_path=BASHRC_PATH)
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.remove_alias(alias_name, file_path=BASHRC_PATH)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkalias
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti