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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5adafac586340239d903cce9c523a485ae8c89f6
4
- data.tar.gz: a0395fd57a3760d16dc43b83b2cb66d22e3afbf7
3
+ metadata.gz: 72ae3fa04fedabf736d8cf93aa73a6636517b09e
4
+ data.tar.gz: 3f0942aa03a914e78482bbd9249f999f66757f3b
5
5
  SHA512:
6
- metadata.gz: 2f55c68319d8cb2c8357dce2c63c9e73c6fddec3bd84c85bf51192f621f32dabd82f7fb993c5c0c185c3f1a90aa115f875c8c7fe61b40258cc1235e0c15f11e7
7
- data.tar.gz: 076eb85859d8d45124730255074e535e7715b5dd54aad19a2640426193137b900178c8453d3094f6230758392b23a5bacdc404dc30a0348372516128976ebdfc
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
- TODO: Write usage instructions here
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('shell_file_path', true)]
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
- `cd ~`
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
- @shell_path = File.expand_path(@shell_relative_path, Dir.pwd)
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
@@ -1,3 +1,3 @@
1
1
  module Commanding
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-03 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler