runfile 0.10.3 → 0.11.0

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
  SHA256:
3
- metadata.gz: db827cdc746062590a265cab368b2dacfbd63ab218b2d3ed64f102778d2f8154
4
- data.tar.gz: 24377c69ad88447b525932d8de00b8ad59699edc40a63130338680c64cc56bf4
3
+ metadata.gz: 1b9025fd4b3e8a2ee35daaeb3b9c058732bfc88fc88891381761b2ee80b8d7fc
4
+ data.tar.gz: 7586f94445866e5819a7d29667056c7f2cca94ed4b41e448396c17e9964bc474
5
5
  SHA512:
6
- metadata.gz: 86f0ed22c47f8fcd051dfff82ea0f973ce753f39ed8feefc39e75815c45ccbeb20650ac9c26445e4288435649b64c3372dfb257f8a3675305299bfd08858f3ba
7
- data.tar.gz: cdecf28610bc5f0e07e8a549124e5a59820c2740b25d1045861ad8c644d97297e5f2a63e5d3271e3f17dda695f8b38b794c9e10c586bba5cd90e5c8da5b807ef
6
+ metadata.gz: 87af85bbce27734b356fee01ed2097d5f77fc9fdc2f44f251cf5ccb07562944bc53c9b52c30602d0b991e5c6b9eb03ddb8195b23923812d4184bd5164cec9401
7
+ data.tar.gz: d3ac178489ca8e8a3a99090d035e2d57cf55d5f93a8199d18a7ac9150d27d2ac48b1c4d70b1d45f9cf2b79f55327aeb1847b0f4a9ae73749cf787ea47b90bb58
@@ -22,6 +22,7 @@ module Runfile
22
22
  @summary = options.summary
23
23
  @actions = options.actions
24
24
  @options = options.options
25
+ @params = options.params
25
26
  @examples = options.examples
26
27
  end
27
28
 
@@ -35,6 +36,7 @@ module Runfile
35
36
  doc += docopt_usage
36
37
  doc += docopt_commands width
37
38
  doc += docopt_options width
39
+ doc += docopt_params width
38
40
  doc += docopt_examples width
39
41
  doc.join "\n"
40
42
  end
@@ -74,17 +76,12 @@ module Runfile
74
76
  @options['Options'] = {} unless @options['Options']
75
77
  @options['Options']['-h --help'] = 'Show this screen'
76
78
  @options['Options']['--version'] = 'Show version number' if @version
79
+ section_block @options, width
80
+ end
77
81
 
78
- doc = []
79
- @options.each do |scope, values|
80
- doc << "#{scope}:"
81
- values.each do |flag, text|
82
- helpline = " #{text}"
83
- wrapped = word_wrap helpline, width
84
- doc << " #{flag}\n#{wrapped}\n"
85
- end
86
- end
87
- doc
82
+ # Return all docopt params for 'Params' section
83
+ def docopt_params(width)
84
+ section_block @params, width
88
85
  end
89
86
 
90
87
  # Return all docopt lines for the 'Examples' section
@@ -101,6 +98,21 @@ module Runfile
101
98
  doc
102
99
  end
103
100
 
101
+ # Return a generic block containing scope section (e.g. "Options"),
102
+ # followed by key value paragraphs.
103
+ def section_block(definitions, width)
104
+ doc = []
105
+ definitions.each do |scope, values|
106
+ doc << "#{scope}:"
107
+ values.each do |label, text|
108
+ helpline = " #{text}"
109
+ wrapped = word_wrap helpline, width
110
+ doc << " #{label}\n#{wrapped}\n"
111
+ end
112
+ end
113
+ doc
114
+ end
115
+
104
116
  # Call the docopt handler, which will either return a parsed
105
117
  # arguments list, or halt execution and show usage.
106
118
  def args(argv)
@@ -43,6 +43,12 @@ module Runfile
43
43
  Runner.instance.add_option flag, text, scope
44
44
  end
45
45
 
46
+ # Add a parameter (can be called multiple times)
47
+ # param 'FOLDER', 'Folder to copy'
48
+ def param(name, text, scope=nil)
49
+ Runner.instance.add_param name, text, scope
50
+ end
51
+
46
52
  # Set an example command (can be called multiple times)
47
53
  # example 'server --background'
48
54
  def example(text)
@@ -13,7 +13,8 @@ module Runfile
13
13
  include SettingsMixin
14
14
 
15
15
  attr_accessor :last_usage, :last_help, :name, :version,
16
- :summary, :namespace, :superspace, :actions, :examples, :options
16
+ :summary, :namespace, :superspace, :actions, :examples, :options,
17
+ :params
17
18
 
18
19
  # Initialize all variables to sensible defaults.
19
20
  def initialize
@@ -23,6 +24,7 @@ module Runfile
23
24
  @namespace = nil # dsl: command
24
25
  @actions = {} # dsl: action
25
26
  @options = {} # dsl: option
27
+ @params = {} # dsl: param
26
28
  @examples = [] # dsl: example
27
29
  @name = "Runfile" # dsl: name
28
30
  @version = false # dsl: version
@@ -72,6 +74,13 @@ module Runfile
72
74
  @options[scope][flag] = text
73
75
  end
74
76
 
77
+ # Add a patameter and its help text.
78
+ def add_param(name, text, scope=nil)
79
+ scope or scope = 'Parameters'
80
+ @params[scope] ||= {}
81
+ @params[scope][name] = text
82
+ end
83
+
75
84
  # Add example command.
76
85
  def add_example(command)
77
86
  @examples << (@namespace ? "#{@namespace} #{command}" : command)
@@ -1,3 +1,3 @@
1
1
  module Runfile
2
- VERSION = "0.10.3"
2
+ VERSION = "0.11.0"
3
3
  end
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.10.3
4
+ version: 0.11.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-10-08 00:00:00.000000000 Z
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole