sickle 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/lib/sickle.rb +9 -1
- data/lib/sickle/version.rb +1 -1
- data/spec/main_spec.rb +13 -11
- data/spec/test_app.rb +4 -4
- 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: b2f5904d330566cc14a1192320f794ea44fbbe0e
|
4
|
+
data.tar.gz: a923b565c28675350b0a39ec8c18a9c99d218d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f0fab73721dfde86f4998b092e9258bf4f5c74f4e77de1dc8946d069a9591d614b3f21c0f9ea2be394c6170cdaafabe1b3112075a3f6c53445f0b05756ee190
|
7
|
+
data.tar.gz: 457d31092578700dde68a3caa60ba193985998914308edec4630152050e6d73b404b1d43b52be8a5036dd26c662fb2347f61bbddb7520a16a7468a013c6c7784
|
data/README.md
CHANGED
@@ -43,14 +43,15 @@ require "sickle"
|
|
43
43
|
class App
|
44
44
|
include Sickle::Runner
|
45
45
|
|
46
|
-
|
46
|
+
global_flag :verbose # global flag, defaults to false
|
47
|
+
global_option :with_prefix # global option, defaults to nil
|
47
48
|
|
48
49
|
desc "install one of the available apps" # command description
|
49
|
-
|
50
|
+
flag :force # flag for `install` command
|
50
51
|
option :host, :default => "localhost" # option
|
51
52
|
def install(name)
|
52
|
-
if options[:
|
53
|
-
|
53
|
+
if options[:force] # access options
|
54
|
+
do_smth_with options[:host]
|
54
55
|
end
|
55
56
|
# the rest
|
56
57
|
end
|
@@ -82,7 +83,7 @@ USAGE:
|
|
82
83
|
mytool COMMAND [ARG1, ARG2, ...] [OPTIONS]
|
83
84
|
|
84
85
|
TASKS:
|
85
|
-
help [COMMAND]
|
86
|
+
help [COMMAND]
|
86
87
|
install NAME # install one of the available apps
|
87
88
|
list [SEARCH] # list all apps, search is possible
|
88
89
|
|
@@ -168,7 +169,7 @@ USAGE:
|
|
168
169
|
|
169
170
|
TASKS:
|
170
171
|
fun # have some fun at top level
|
171
|
-
help [COMMAND]
|
172
|
+
help [COMMAND]
|
172
173
|
main # top level command
|
173
174
|
p:list # list all projects
|
174
175
|
users:create NAME # create new user
|
data/lib/sickle.rb
CHANGED
@@ -66,7 +66,7 @@ module Sickle
|
|
66
66
|
def initialize(name, opts)
|
67
67
|
@name, @opts = name, opts
|
68
68
|
|
69
|
-
@default = opts.has_key?(:default) ? opts[:default] :
|
69
|
+
@default = opts.has_key?(:default) ? opts[:default] : nil
|
70
70
|
|
71
71
|
if @default == true || @default == false
|
72
72
|
@type = :boolean
|
@@ -198,10 +198,18 @@ module Sickle
|
|
198
198
|
__global_options[name.to_s] = Option.new(name, opts)
|
199
199
|
end
|
200
200
|
|
201
|
+
def global_flag(name)
|
202
|
+
global_option(name, :default => false)
|
203
|
+
end
|
204
|
+
|
201
205
|
def option(name, opts = {})
|
202
206
|
Sickle.push_option(name, opts)
|
203
207
|
end
|
204
208
|
|
209
|
+
def flag(name)
|
210
|
+
option(name, :default => false)
|
211
|
+
end
|
212
|
+
|
205
213
|
def include_modules(hash)
|
206
214
|
hash.each do |key, value|
|
207
215
|
Sickle.push_namespace(key)
|
data/lib/sickle/version.rb
CHANGED
data/spec/main_spec.rb
CHANGED
@@ -31,26 +31,28 @@ describe Sickle do
|
|
31
31
|
describe "Runner" do
|
32
32
|
it "task1" do
|
33
33
|
App.run(["task1", "x", "y"]).must_equal(
|
34
|
-
["task1", "x", "y", "def", false, false,
|
35
|
-
App.run(["task1", "x", "y", "z", "--verbose", "--with-prefix"]).must_equal(
|
36
|
-
["task1", "x", "y", "z", false, true,
|
34
|
+
["task1", "x", "y", "def", false, false, nil, nil])
|
35
|
+
App.run(["task1", "x", "y", "z", "--verbose", "--with-prefix", "some/path/to"]).must_equal(
|
36
|
+
["task1", "x", "y", "z", false, true, nil, "some/path/to"])
|
37
|
+
App.run(["task1", "--verbose", "x", "y"]).must_equal(
|
38
|
+
["task1", "x", "y", "def", false, true, nil, nil])
|
37
39
|
end
|
38
40
|
|
39
41
|
it "task2" do
|
40
42
|
App.run(["task2"]).must_equal(
|
41
|
-
["task2", 10, false, false, false,
|
43
|
+
["task2", 10, false, false, false, nil])
|
42
44
|
App.run(%w(task2 --fast)).must_equal(
|
43
|
-
["task2", 10, true, false, false,
|
45
|
+
["task2", 10, true, false, false, nil])
|
44
46
|
App.run(%w(task2 --slow)).must_equal(
|
45
|
-
["task2", 10, false, true, false,
|
47
|
+
["task2", 10, false, true, false, nil])
|
46
48
|
App.run(%w(task2 --verbose)).must_equal(
|
47
|
-
["task2", 10, false, false, true,
|
48
|
-
App.run(%w(task2 --debug)).must_equal(
|
49
|
-
["task2", 10, false, false, false,
|
49
|
+
["task2", 10, false, false, true, nil])
|
50
|
+
App.run(%w(task2 --debug 1)).must_equal(
|
51
|
+
["task2", 10, false, false, false, "1"])
|
50
52
|
App.run(%w(task2 --fast --slow --verbose)).must_equal(
|
51
|
-
["task2", 10, true, true, true,
|
53
|
+
["task2", 10, true, true, true, nil])
|
52
54
|
App.run(%w(task2 --number 40)).must_equal(
|
53
|
-
["task2", 40, false, false, false,
|
55
|
+
["task2", 40, false, false, false, nil])
|
54
56
|
end
|
55
57
|
|
56
58
|
it "sub:sub1" do
|
data/spec/test_app.rb
CHANGED
@@ -45,19 +45,19 @@ end
|
|
45
45
|
class App
|
46
46
|
include Sickle::Runner
|
47
47
|
|
48
|
-
|
48
|
+
global_flag :verbose
|
49
49
|
global_option :debug
|
50
50
|
|
51
51
|
desc "Run task 1"
|
52
|
-
|
52
|
+
flag :quiet
|
53
53
|
option :with_prefix
|
54
54
|
def task1(a, b, c = "def")
|
55
55
|
p ["task1", a, b, c, options[:quiet], options[:verbose], options[:debug], options[:with_prefix]]
|
56
56
|
end
|
57
57
|
|
58
58
|
desc "Run task 2"
|
59
|
-
|
60
|
-
|
59
|
+
flag :fast
|
60
|
+
flag :slow
|
61
61
|
option :number, :default => 10
|
62
62
|
def task2
|
63
63
|
p ["task2", options[:number], options[:fast], options[:slow], options[:verbose], options[:debug]]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sickle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tymon Tobolski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|