commanding 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -2
- data/lib/commanding.rb +15 -6
- data/lib/commanding/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ae3fa04fedabf736d8cf93aa73a6636517b09e
|
4
|
+
data.tar.gz: 3f0942aa03a914e78482bbd9249f999f66757f3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c71d180e3aef8227d2879792ce8025452b024615d2ecd36e7edc98d3dba75d528b7e9d2b3211b2cb89411b3ff2d98d9b86a79344133292eb98a2980087b25a16
|
7
|
+
data.tar.gz: fbefe1df3bca1a0a7f5623265514dfd9031e8a64e3337cdfe1a683b47aaf26a56ce386cbca9c60d0675aeb698c65b1dbd22ea55f7efa3ddf609c38ad5ba0089c
|
data/README.md
CHANGED
@@ -22,7 +22,47 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Run this command:
|
26
|
+
|
27
|
+
```
|
28
|
+
commanding install new_command_name shell_relative_path
|
29
|
+
```
|
30
|
+
then a command line tool named **new_command_name** will be created, which link to
|
31
|
+
**shell_relative_path**. When you run new_command_name, actually the shell file at
|
32
|
+
**shell_relative_path** will run.
|
33
|
+
|
34
|
+
When you don't need the **new_command_name**, just run this command:
|
35
|
+
|
36
|
+
```
|
37
|
+
commanding uninstall new_command_name
|
38
|
+
```
|
39
|
+
|
40
|
+
then this command **new_command_name** will be removed.
|
41
|
+
|
42
|
+
if after **commanding** run, nothing to happen, just quit current terminal, and then
|
43
|
+
restart it.
|
44
|
+
|
45
|
+
### Example
|
46
|
+
|
47
|
+
if you develop a shell file to pull code from the right remote branch, here suppose the
|
48
|
+
shell path you developed is pull.sh. In the past you need to run this pull.sh at its parent
|
49
|
+
directory, you can't directly run this pull.sh at other project. But with is **commanding**
|
50
|
+
command line tool, everythins become easy. Just run this command at pull.sh parent directory:
|
51
|
+
|
52
|
+
```
|
53
|
+
commanding install pull pull.sh
|
54
|
+
```
|
55
|
+
Then you can run pull at any git project. After then pull code become this:
|
56
|
+
|
57
|
+
```
|
58
|
+
pull
|
59
|
+
```
|
60
|
+
When someday the pull command no needed, just run this command:
|
61
|
+
|
62
|
+
```
|
63
|
+
commanding uninstall pull
|
64
|
+
```
|
65
|
+
Then it clean.
|
26
66
|
|
27
67
|
## Development
|
28
68
|
|
@@ -38,4 +78,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
38
78
|
## License
|
39
79
|
|
40
80
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/commanding.rb
CHANGED
@@ -12,10 +12,16 @@ module Commanding
|
|
12
12
|
be relative path to current directory.
|
13
13
|
DESC
|
14
14
|
|
15
|
+
def shell_config_name
|
16
|
+
if !@shell_config_name
|
17
|
+
shell_name = File.basename(`echo $SHELL`)
|
18
|
+
@shell_config_name = '.' + shell_name.strip + 'rc'
|
19
|
+
end
|
20
|
+
@shell_config_name
|
21
|
+
end
|
22
|
+
|
15
23
|
def shell_config_path
|
16
24
|
if !@shell_config_path
|
17
|
-
shell_name = File.basename(`echo $SHELL`)
|
18
|
-
shell_config_name = '.' + shell_name.strip + 'rc'
|
19
25
|
@shell_config_path = File.expand_path("~/"+shell_config_name)
|
20
26
|
end
|
21
27
|
@shell_config_path
|
@@ -27,7 +33,7 @@ module Commanding
|
|
27
33
|
self.summary = 'Make a command line tool or *.sh run any directory.'
|
28
34
|
|
29
35
|
self.arguments = [CLAide::Argument.new('new_command_name', true),
|
30
|
-
CLAide::Argument.new('
|
36
|
+
CLAide::Argument.new('shell_relative_path', true)]
|
31
37
|
|
32
38
|
def initialize(argv)
|
33
39
|
@new_command_name = argv.shift_argument
|
@@ -43,7 +49,7 @@ module Commanding
|
|
43
49
|
end
|
44
50
|
|
45
51
|
def run
|
46
|
-
|
52
|
+
File.chmod(777, shell_path) unless File.executable?(shell_path)
|
47
53
|
|
48
54
|
file = nil
|
49
55
|
if File.exists?(shell_config_path)
|
@@ -54,11 +60,14 @@ module Commanding
|
|
54
60
|
file.write("\n")
|
55
61
|
file.write("alias #{@new_command_name}=\"#{@shell_path}\"")
|
56
62
|
file.close
|
63
|
+
|
64
|
+
`source #{"~/" + shell_config_name}`
|
57
65
|
end
|
58
66
|
|
59
67
|
def shell_path
|
60
68
|
if !@shell_path
|
61
|
-
|
69
|
+
expanded_relative_path = File.expand_path(@shell_relative_path)
|
70
|
+
@shell_path = File.expand_path(expanded_relative_path, Dir.pwd)
|
62
71
|
end
|
63
72
|
@shell_path
|
64
73
|
end
|
@@ -82,7 +91,6 @@ module Commanding
|
|
82
91
|
end
|
83
92
|
|
84
93
|
def run
|
85
|
-
`cd ~`
|
86
94
|
if File.exists?(shell_config_path)
|
87
95
|
file = File.open(shell_config_path, 'r+')
|
88
96
|
file.each do |line|
|
@@ -98,6 +106,7 @@ module Commanding
|
|
98
106
|
help! 'No #{@installed_command_name}, nothing to remove.'
|
99
107
|
end
|
100
108
|
|
109
|
+
`source #{"~/" + shell_config_name}`
|
101
110
|
end
|
102
111
|
|
103
112
|
end
|
data/lib/commanding/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commanding
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 从权
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|