runfile 0.11.1 → 0.11.2
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/lib/runfile/docopt_helper.rb +7 -0
- data/lib/runfile/dsl.rb +6 -0
- data/lib/runfile/runner.rb +14 -6
- data/lib/runfile/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1e4e930d902a8bb8db9d283e1cf7c33fb26c5e1dfdf77b03d5be0a3acc01609
|
4
|
+
data.tar.gz: cf2bf1976c2dee358a8bbd2b9465b871bc6c9630c0ca7f091000b2464615370c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eaadbedb085b6a8ef13078327b2260c82fc86baebf2292868eb7d37c166206e8b529a82a67e39fbe3a1087271308d5f750ff07bea8c515e9b065d7e413cdf65
|
7
|
+
data.tar.gz: f837dd093b39741dabc2e67813bcd21f9ff7bdac3b52cb90990fe9b568f90801e5c344e697224ddce095af478fc7e92ace4d5be8867c97827b4627f93dd7535e
|
@@ -23,6 +23,7 @@ module Runfile
|
|
23
23
|
@actions = options.actions
|
24
24
|
@options = options.options
|
25
25
|
@params = options.params
|
26
|
+
@env_vars = options.env_vars
|
26
27
|
@examples = options.examples
|
27
28
|
end
|
28
29
|
|
@@ -37,6 +38,7 @@ module Runfile
|
|
37
38
|
doc += docopt_commands width
|
38
39
|
doc += docopt_options width
|
39
40
|
doc += docopt_params width
|
41
|
+
doc += docopt_env_vars width
|
40
42
|
doc += docopt_examples width
|
41
43
|
doc.join "\n"
|
42
44
|
end
|
@@ -84,6 +86,11 @@ module Runfile
|
|
84
86
|
section_block @params, width
|
85
87
|
end
|
86
88
|
|
89
|
+
# Return all docopt params for 'Environment Variables' section
|
90
|
+
def docopt_env_vars(width)
|
91
|
+
section_block @env_vars, width
|
92
|
+
end
|
93
|
+
|
87
94
|
# Return all docopt lines for the 'Examples' section
|
88
95
|
def docopt_examples(width)
|
89
96
|
return [] if @examples.empty?
|
data/lib/runfile/dsl.rb
CHANGED
@@ -49,6 +49,12 @@ module Runfile
|
|
49
49
|
Runner.instance.add_param name, text, scope
|
50
50
|
end
|
51
51
|
|
52
|
+
# Set an environment variable (can be called multiple times)
|
53
|
+
# env_var 'USER', 'Set the user (same as --user)'
|
54
|
+
def env_var(name, text, scope = nil)
|
55
|
+
Runner.instance.add_env_var name, text, scope
|
56
|
+
end
|
57
|
+
|
52
58
|
# Set an example command (can be called multiple times)
|
53
59
|
# example 'server --background'
|
54
60
|
def example(text)
|
data/lib/runfile/runner.rb
CHANGED
@@ -14,7 +14,7 @@ module Runfile
|
|
14
14
|
|
15
15
|
attr_accessor :last_usage, :last_help, :name, :version,
|
16
16
|
:summary, :namespace, :superspace, :actions, :examples, :options,
|
17
|
-
:params
|
17
|
+
:params, :env_vars
|
18
18
|
|
19
19
|
# Initialize all variables to sensible defaults.
|
20
20
|
def initialize
|
@@ -26,6 +26,7 @@ module Runfile
|
|
26
26
|
@options = {} # dsl: option
|
27
27
|
@params = {} # dsl: param
|
28
28
|
@examples = [] # dsl: example
|
29
|
+
@env_vars = {} # dsl: env_var
|
29
30
|
@name = "Runfile" # dsl: name
|
30
31
|
@version = false # dsl: version
|
31
32
|
@summary = false # dsl: summary
|
@@ -48,7 +49,7 @@ module Runfile
|
|
48
49
|
|
49
50
|
# Add an action to the @actions array, and use the last known
|
50
51
|
# usage and help messages sent by the DSL.
|
51
|
-
def add_action(name, altname=nil, &block)
|
52
|
+
def add_action(name, altname = nil, &block)
|
52
53
|
if @last_usage.nil?
|
53
54
|
@last_usage = altname ? "(#{name}|#{altname})" : name
|
54
55
|
end
|
@@ -68,19 +69,26 @@ module Runfile
|
|
68
69
|
end
|
69
70
|
|
70
71
|
# Add an option flag and its help text.
|
71
|
-
def add_option(flag, text, scope=nil)
|
72
|
-
scope
|
72
|
+
def add_option(flag, text, scope = nil)
|
73
|
+
scope ||= 'Options'
|
73
74
|
@options[scope] ||= {}
|
74
75
|
@options[scope][flag] = text
|
75
76
|
end
|
76
77
|
|
77
78
|
# Add a patameter and its help text.
|
78
|
-
def add_param(name, text, scope=nil)
|
79
|
-
scope
|
79
|
+
def add_param(name, text, scope = nil)
|
80
|
+
scope ||= 'Parameters'
|
80
81
|
@params[scope] ||= {}
|
81
82
|
@params[scope][name] = text
|
82
83
|
end
|
83
84
|
|
85
|
+
# Add env_var command.
|
86
|
+
def add_env_var(name, text, scope = nil)
|
87
|
+
scope ||= 'Environment Variables'
|
88
|
+
@env_vars[scope] ||= {}
|
89
|
+
@env_vars[scope][name] = text
|
90
|
+
end
|
91
|
+
|
84
92
|
# Add example command.
|
85
93
|
def add_example(command)
|
86
94
|
@examples << (@namespace ? "#{@namespace} #{command}" : command)
|
data/lib/runfile/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.2
|
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: 2020-
|
11
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.1.
|
87
|
+
rubygems_version: 3.1.4
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: If Rake and Docopt had a baby
|