ralias 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -2
- data/lib/ralias/command.rb +16 -20
- data/lib/ralias/define_commands.rb +17 -4
- data/lib/ralias/version.rb +1 -1
- data/ralias.gemspec +2 -2
- metadata +8 -8
data/README.md
CHANGED
data/lib/ralias/command.rb
CHANGED
@@ -41,32 +41,28 @@ module Ralias
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def run(_cmd, args)
|
44
|
-
cmd = commands[_cmd]
|
44
|
+
cmd = commands[_cmd] || (raise CommandNotFound)
|
45
45
|
required_args = cmd.parameters
|
46
46
|
|
47
|
-
|
48
|
-
if
|
49
|
-
|
50
|
-
cmd.call(*args)
|
51
|
-
else
|
52
|
-
system cmd.call(*args)
|
53
|
-
end
|
47
|
+
if required_args.size == args.size
|
48
|
+
if built_in_commands.include?(_cmd)
|
49
|
+
cmd.call(*args)
|
54
50
|
else
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
required_args.
|
60
|
-
with_color { "argumets: " + arg[1].to_s }
|
61
|
-
end
|
62
|
-
raise CommandNotFound
|
51
|
+
(system cmd.call(*args))
|
52
|
+
end
|
53
|
+
else
|
54
|
+
with_color(:red) do
|
55
|
+
"wrong number of arguments (#{args.size} for #{required_args.size}) (ArgumentError)"
|
63
56
|
end
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
with_color(:red) { "error in the definition file." }
|
58
|
+
required_args.each do |arg|
|
59
|
+
with_color { "argumets: " + arg[1].to_s }
|
60
|
+
end
|
69
61
|
end
|
62
|
+
rescue CommandNotFound
|
63
|
+
with_color(:red) { "command not found." }
|
64
|
+
rescue
|
65
|
+
with_color(:red) { "error in the definition file." }
|
70
66
|
end
|
71
67
|
end
|
72
68
|
end
|
@@ -21,13 +21,13 @@ HELP
|
|
21
21
|
#
|
22
22
|
# normal alias definition
|
23
23
|
#
|
24
|
-
#
|
24
|
+
# define("lsA") { "ls -al" }
|
25
25
|
#
|
26
26
|
# if you want to use the arguments to the alias
|
27
27
|
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
28
|
+
# define("github") do |user_name, repository|
|
29
|
+
# "git clone https://github.com/#{user_name}/#{repository}.git"
|
30
|
+
# end
|
31
31
|
#
|
32
32
|
EXAMPLE
|
33
33
|
end
|
@@ -55,4 +55,17 @@ HELP
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
built_in_commands << "list"
|
58
|
+
|
59
|
+
#
|
60
|
+
# Use in the command function here
|
61
|
+
#
|
62
|
+
class << self
|
63
|
+
def b_cd(command = "")
|
64
|
+
%Q(cd #{command.to_s} && exec /bin/bash)
|
65
|
+
end
|
66
|
+
|
67
|
+
def z_cd(command = "")
|
68
|
+
%Q(cd #{command.to_s} && exec /bin/zsh)
|
69
|
+
end
|
70
|
+
end
|
58
71
|
end
|
data/lib/ralias/version.rb
CHANGED
data/ralias.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# -*-
|
1
|
+
# -*- coding: utf-8; mode: ruby; -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require "ralias/version"
|
4
4
|
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Daic_h"]
|
9
9
|
s.email = ["bunny.hop.md@gmail.com"]
|
10
10
|
s.homepage = ""
|
11
|
-
s.summary = '
|
11
|
+
s.summary = 'can be defined like the alias of shell'
|
12
12
|
s.description = s.summary
|
13
13
|
|
14
14
|
s.rubyforge_project = "ralias"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ralias
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70275622745280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.2.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70275622745280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70275622742760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,8 +32,8 @@ dependencies:
|
|
32
32
|
version: 2.7.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description:
|
35
|
+
version_requirements: *70275622742760
|
36
|
+
description: can be defined like the alias of shell
|
37
37
|
email:
|
38
38
|
- bunny.hop.md@gmail.com
|
39
39
|
executables:
|
@@ -80,7 +80,7 @@ rubyforge_project: ralias
|
|
80
80
|
rubygems_version: 1.8.10
|
81
81
|
signing_key:
|
82
82
|
specification_version: 3
|
83
|
-
summary:
|
83
|
+
summary: can be defined like the alias of shell
|
84
84
|
test_files:
|
85
85
|
- spec/command_spec.rb
|
86
86
|
- spec/spec_helper.rb
|