mister_bin 0.0.2 → 0.1.0

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
  SHA256:
3
- metadata.gz: 145d72d39990c48d376b0090537d3ddd682ea2288fdea8ef96028f0745ecd60d
4
- data.tar.gz: bc3bc649a79b06e746a260d7d0e0c19c973b3c29cf76bf966b4f621b261743c5
3
+ metadata.gz: 4855be0420ff86441a00e588e967c8b2853b421a29965fd834a565867889c9c6
4
+ data.tar.gz: 3091bd565021ec3e53e42b33f5a6bbde9ae204f15bc8afb30a9b1fd3bf233c2d
5
5
  SHA512:
6
- metadata.gz: 0e83d1905b8bfdc7e9d1e66a402fc3eaaf87ecf8a240a535d08a4b1d67b11b76062fcd78b2df06c84cae1a738c866fa0ab5081413f83fec5b70a64fb386de7f4
7
- data.tar.gz: 7e1a2a406f3245786f36d2662532e17976f4e5f0b348febf303ef65b5f13c00b35465be6e9c86aa6ba9aa3304b13440a24d244cf3fd1a75e940af16a464ba33a
6
+ metadata.gz: f58f8e52666cd8461f500d19165271d349871ec7d7bdb6f3b10104097ae3657d3055ce79b67bed4d30c1221ed0720b5d14a8ccd0bef0769dc57f73aafbb11632
7
+ data.tar.gz: 5e67542db23b0ff6d65307d702f5559259fd8f7ee645977d961d5791f023e375777553250cf470d7cc2fa10595bae165ea8e228443cccec20a94efbdac241585
data/README.md CHANGED
@@ -27,6 +27,13 @@ Design Goals
27
27
 
28
28
 
29
29
 
30
+ Example
31
+ --------------------------------------------------
32
+
33
+ See the [example](/example) folder.
34
+
35
+
36
+
30
37
  Usage
31
38
  --------------------------------------------------
32
39
 
@@ -105,7 +112,7 @@ require 'mister_bin'
105
112
  exit MisterBin::Runner.run __FILE__, ARGV
106
113
  ```
107
114
 
108
- This code will start the execution chain based on the arguments provided
115
+ It will start the execution chain based on the arguments provided
109
116
  when running it.
110
117
 
111
118
  The `Runner.run` method requires two parameters:
@@ -114,6 +121,21 @@ The `Runner.run` method requires two parameters:
114
121
  need).
115
122
  2. An array of arguments (usually `ARGV` is what you need).
116
123
 
124
+ In addition, you may provide a `header` and a `footer` that will be
125
+ displayed when executing without arguments:
126
+
127
+ ```ruby
128
+ # git
129
+ #!/usr/bin/env ruby
130
+ require 'mister_bin'
131
+
132
+ exitcode = MisterBin::Runner.run __FILE__, ARGV,
133
+ header: "This is a sample header.",
134
+ footer: "This is a sample footer."
135
+
136
+ exit exitcode
137
+ ```
138
+
117
139
 
118
140
 
119
141
  Creating Subcommands
@@ -1,13 +1,19 @@
1
+ require 'colsole'
2
+
1
3
  module MisterBin
2
4
  class Runner
3
- attr_reader :basefile, :basedir, :name
5
+ include Colsole
6
+
7
+ attr_reader :basefile, :basedir, :name, :header, :footer
4
8
 
5
- def self.run(basefile, argv=[])
6
- new(basefile).run argv
9
+ def self.run(basefile, argv=[], header: nil, footer: nil)
10
+ new(basefile, header: header, footer: footer).run argv
7
11
  end
8
12
 
9
- def initialize(basefile)
13
+ def initialize(basefile, header: nil, footer: nil)
10
14
  @basefile = basefile
15
+ @header = header
16
+ @footer = footer
11
17
  @basedir = File.dirname basefile
12
18
  @name = File.basename basefile
13
19
  end
@@ -28,8 +34,8 @@ module MisterBin
28
34
  if command
29
35
  execute_command command, argv
30
36
  else
31
- puts "Unknown command: #{argv[0]}"
32
- return 1
37
+ puts "Unknown command: #{argv[0]}\n\n"
38
+ show_subs
33
39
  end
34
40
  end
35
41
 
@@ -41,8 +47,10 @@ module MisterBin
41
47
  if commands.all.empty?
42
48
  puts "No subcommands found"
43
49
  else
44
- puts "Usage:"
50
+ say "#{header}\n" if header
51
+ puts "Commands:"
45
52
  commands.names.each { |command| puts " #{name} #{command}" }
53
+ say "\n#{footer}" if footer
46
54
  end
47
55
 
48
56
  return 1
@@ -1,3 +1,3 @@
1
1
  module MisterBin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mister_bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-14 00:00:00.000000000 Z
11
+ date: 2018-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole