mkalias 1.0.1 → 1.0.2

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: 6b885a1373ff93b5d1ae54cc7a39a2d134707b8a
4
- data.tar.gz: 0f069ffbc58990b6d28399694017ad6d8e5e7531
3
+ metadata.gz: d5f0ed02cffd4fd402e3fea1016a1db825997e93
4
+ data.tar.gz: ce009d8d94ea833636cb5d924af3ce5a106c875f
5
5
  SHA512:
6
- metadata.gz: 809aff07e54b5f98303f667327c01ac6aecb48899f92d10c47979a4a27f579c328c8c3423c01fd28fc165e78c96fee371766d9d4ffc20db5be22320772adc163
7
- data.tar.gz: 1673ec8d1f245b7098ea9cf610eb9e9cd02665ddeb743e935ce7b76e5f25eeb0b6afae38b90ec343f1418af3f75e559276d7da8eef62c7b678ee685cd5fd80cc
6
+ metadata.gz: ee5f8c14eaf0c779e834b4e8fead6f83ef31393a3691faa347a6f06474ab03bdb19d2d205dda3b3265633bfaa0c15c877f6ec7a5d5976134c484877569cd434c
7
+ data.tar.gz: 9c24bde9def58e83db15a43a8f4671c58bfaf0e11a408f10f73594073c92425966e1d34b3723b75e2f7523b9b686943b9db3d007b71aaebf6307ef85cd35a3d9
data/README.md CHANGED
@@ -23,20 +23,22 @@ Or install it yourself as:
23
23
 
24
24
  run: $ mkalias [option]
25
25
 
26
- option: new -> mkalias new [alias] [command 1] [command 2] ... [command n]
27
- - Create a new alias to run the commands
26
+ options:
28
27
 
29
- option: list -> mkalias list
30
- - List all alias
28
+ new $ mkalias new [alias] [command 1] [command 2] ... [command n]
29
+ - Create a new alias to run the commands
31
30
 
32
- option: show -> mkalias show
33
- - Show commands of all alias
31
+ list $ mkalias list
32
+ - List all alias
34
33
 
35
- option: show -> mkalias show [alias 1] [alias 2] ... [alias n]
36
- - Show commands of the specified alias
34
+ show $ mkalias show
35
+ - Show commands of all alias
37
36
 
38
- option: remove -> mkalias remove [alias 1] [alias 2] ... [alias n]
39
- - Remove the specified alias
37
+ $ mkalias show [alias 1] [alias 2] ... [alias n]
38
+ - Show commands of the specified alias
39
+
40
+ remove $ mkalias remove [alias 1] [alias 2] ... [alias n]
41
+ - Remove the specified alias
40
42
 
41
43
  Attention: To make alias with args use #. Example:
42
44
  $ mkalias new [alias] "echo #1 #2 #3"
data/bin/mkalias CHANGED
@@ -8,25 +8,27 @@ VALID_OPTIONS = ['new', 'list', 'show', 'remove']
8
8
  def usage
9
9
  puts "Usage: mkalias [option]"
10
10
  puts ""
11
- puts "option: new \t -> mkalias new [alias] [command 1] [command 2] ..." \
11
+ puts "options:"
12
+ puts ""
13
+ puts " new \t\t $ mkalias new [alias] [command 1] [command 2] ..." \
12
14
  " [command n]"
13
- puts "- Create a new alias to run the commands"
15
+ puts "\t\t - Create a new alias to run the commands"
14
16
  puts ""
15
- puts "option: list \t -> mkalias list"
16
- puts "- List all alias"
17
+ puts " list \t\t $ mkalias list"
18
+ puts "\t\t - List all alias"
17
19
  puts ""
18
- puts "option: show \t -> mkalias show"
19
- puts "- Show commands of all alias"
20
+ puts " show \t\t $ mkalias show"
21
+ puts "\t\t - Show commands of all alias"
20
22
  puts ""
21
- puts "option: show \t -> mkalias show [alias 1] [alias 2] ... [alias n]"
22
- puts "- Show commands of the specified alias"
23
+ puts "\t\t $ mkalias show [alias 1] [alias 2] ... [alias n]"
24
+ puts "\t\t - Show commands of the specified alias"
23
25
  puts ""
24
- puts "option: remove \t -> mkalias remove [alias 1] [alias 2] ... [alias n]"
25
- puts "- Remove the specified alias"
26
+ puts " remove \t $ mkalias remove [alias 1] [alias 2] ... [alias n]"
27
+ puts "\t\t - Remove the specified alias"
26
28
  puts ""
27
29
  puts "Attention: To make alias with args use #. Example:"
28
- puts " $ mkalias new [alias] \"echo #1 #2 #3\""
29
- puts " - Then you can use: $ [alias] arg1 arg2 arg3"
30
+ puts " $ mkalias new [alias] \"echo #1 #2 #3\""
31
+ puts " - Then you can use: $ [alias] arg1 arg2 arg3"
30
32
  abort
31
33
  end
32
34
 
@@ -72,11 +74,11 @@ def show_alias
72
74
  end
73
75
 
74
76
  unless commands.empty?
75
- commands.each do |alias_name, alias_functions|
77
+ commands.each do |alias_name, alias_commands|
76
78
  puts "-> #{alias_name}"
77
79
 
78
- alias_functions.each do |alias_function|
79
- puts " $ #{alias_function}"
80
+ alias_commands.each do |alias_command|
81
+ puts " $ #{alias_command}"
80
82
  end
81
83
  puts ""
82
84
  end
@@ -1,3 +1,3 @@
1
1
  module Mkalias
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/mkalias.rb CHANGED
@@ -42,14 +42,14 @@ module Mkalias
42
42
  def self.show_alias(alias_names, file_path=BASHRC_PATH)
43
43
  alias_names = [alias_names] unless alias_names.kind_of?(Array)
44
44
 
45
- alias_functions = {}
45
+ alias_commands = {}
46
46
  alias_names.each do |alias_name|
47
- alias_functions[alias_name] = Mkalias.get_alias_function(alias_name,
47
+ alias_commands[alias_name] = Mkalias.get_alias_command(alias_name,
48
48
  file_path)
49
49
  end
50
50
 
51
- alias_functions.select!{ |key, value| !value.nil? }
52
- return alias_functions
51
+ alias_commands.select!{ |key, value| !value.nil? }
52
+ return alias_commands
53
53
  end
54
54
 
55
55
  def self.remove_alias(alias_names, file_path=BASHRC_PATH)
@@ -66,17 +66,17 @@ module Mkalias
66
66
 
67
67
  private
68
68
 
69
- def self.get_alias_function(alias_name, file_path=BASHRC_PATH)
69
+ def self.get_alias_command(alias_name, file_path=BASHRC_PATH)
70
70
  alias_names = Mkalias.list_alias(file_path)
71
71
  return nil unless alias_names.include?(alias_name)
72
72
 
73
73
  alias_regex = /\bmkalias_#{alias_name}[(]/
74
- function_regex = /[{](.*)[;]/
74
+ command_regex = /[{](.*)[;]/
75
75
 
76
- alias_functions = File.foreach(file_path).grep(alias_regex)
76
+ alias_commands = File.foreach(file_path).grep(alias_regex)
77
77
 
78
- alias_functions.each do |function|
79
- result = function.match(function_regex)
78
+ alias_commands.each do |command|
79
+ result = command.match(command_regex)
80
80
  return result.captures.first.split(';').each{ |c| c.strip! } if result
81
81
  end
82
82
 
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti