runfile 1.0.0.rc4 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -44
- data/lib/runfile/action.rb +8 -6
- data/lib/runfile/concerns/dsl.rb +0 -3
- data/lib/runfile/exceptions.rb +1 -0
- data/lib/runfile/gem_finder.rb +1 -1
- data/lib/runfile/runner.rb +4 -2
- data/lib/runfile/userfile.rb +16 -4
- data/lib/runfile/version.rb +1 -1
- data/lib/runfile.rb +1 -6
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a340ad5324cc9b24104fc460c171300cc2ab9690bb8bdfa2b38442b3ddf81a
|
4
|
+
data.tar.gz: e3f0fe2e7c4ba4fca9058d10f5caffc2daa76d5f0810aa5a63d646d2a23347d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f94f10d4feda0300878584b68c1af769bc1a81392ee52f7716d89d0d7fe376cf9d20cc2cbb8bc0ef35d5574b469de038df67e99dbaa0a077ca4fed7a7cb548c
|
7
|
+
data.tar.gz: 5983f010e720484acdb6b013248c32f4ed104180e7fc05218c93abfaf1a3eea7775b95e7e6e7cbe2c0871316056fe4d99c27b7e1b93b13524782015199a66a8a
|
data/README.md
CHANGED
@@ -9,15 +9,16 @@
|
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
|
-
A beautiful command line
|
13
|
-
Rake-inspired
|
12
|
+
A beautiful command line utility builder
|
13
|
+
Rake-inspired ✦ Docopt inside
|
14
|
+
**[runfile.dannyb.co](https://runfile.dannyb.co)**
|
14
15
|
|
15
16
|
---
|
16
17
|
|
17
18
|
</div>
|
18
19
|
|
19
|
-
**Runfile** lets you create command line
|
20
|
-
|
20
|
+
**Runfile** lets you create command line tools in a way similar to
|
21
|
+
[Rake](https://github.com/ruby/rake), but with the full power of
|
21
22
|
[Docopt](http://docopt.org/) command line options.
|
22
23
|
|
23
24
|
You create a `runfile`, and execute commands with
|
@@ -26,15 +27,9 @@ You create a `runfile`, and execute commands with
|
|
26
27
|
Runfile is designed primarily for Ruby developers, but if you need to add a
|
27
28
|
command line "toolbelt" for your projects, you can use it regardless.
|
28
29
|
|
29
|
-
## Pre-release Notice
|
30
|
-
|
31
|
-
Note that this README describes the not yet released 1.0.0 version.
|
32
|
-
See [runfile.dannyb.co](https://runfile.dannyb.co/) for the stable release
|
33
|
-
documentation.
|
34
|
-
|
35
30
|
## Demo
|
36
31
|
|
37
|
-
![Runfile Demo](
|
32
|
+
![Runfile Demo](support/cast.gif "Runfile Demo")
|
38
33
|
|
39
34
|
## Install
|
40
35
|
|
@@ -110,7 +105,7 @@ Options:
|
|
110
105
|
Show this message
|
111
106
|
```
|
112
107
|
|
113
|
-
|
108
|
+
### More Examples
|
114
109
|
|
115
110
|
You can learn almost everything there is to know about runfile from the
|
116
111
|
[examples](https://github.com/DannyBen/runfile/tree/master/examples#readme).
|
@@ -129,56 +124,67 @@ Note that the current user guide is for the stable version 0.12.0.
|
|
129
124
|
|
130
125
|
## Breaking Changes in 1.0.0
|
131
126
|
|
132
|
-
If you are using a version earlier than 1.0, note that
|
133
|
-
|
134
|
-
Request](https://github.com/DannyBen/runfile/pull/50).
|
127
|
+
If you are using a version earlier than 1.0, note that version 1.0.0 includes
|
128
|
+
some breaking changes. You can read more about them in
|
129
|
+
[this Pull Request](https://github.com/DannyBen/runfile/pull/50).
|
135
130
|
|
136
131
|
### Upgrading to 1.0.0
|
137
132
|
|
138
|
-
|
133
|
+
<details>
|
134
|
+
<summary>Show section</summary>
|
135
|
+
|
136
|
+
### No more `.runfile` config
|
137
|
+
|
138
|
+
If you have used the multi-runfile config file, this no longer exists.
|
139
|
+
Use a standard `runfile` instead, along with the `import` directive.
|
140
|
+
|
141
|
+
### No more `action :global`
|
142
|
+
|
143
|
+
If you have used the `action :global do` notation, this is replaced with the
|
144
|
+
simpler use `action do` instead. Also, there is no more need for
|
145
|
+
empty `usage ''`, just delete it if you have it in your runfiles.
|
146
|
+
|
147
|
+
### No more `execute` directive
|
139
148
|
|
140
|
-
If you have used
|
141
|
-
|
149
|
+
If you have used it to cross-call other actions, it is no longer available. As
|
150
|
+
an alternative, you can define common code in separate classes and `require`
|
151
|
+
them, or use the new `helpers` directive to define functions that will be
|
152
|
+
available to all actions.
|
142
153
|
|
143
|
-
###
|
154
|
+
### Code outside of actions should be inside `helpers`
|
144
155
|
|
145
|
-
If
|
146
|
-
|
147
|
-
empty `usage ''`, just delete it if you have it in your runfiles.
|
156
|
+
If your runfiles include other ruby code, especially `def method`, you should
|
157
|
+
now use the new `helpers` block and tuck this code inside it.
|
148
158
|
|
149
|
-
### No more `
|
159
|
+
### No more need for `trap(:INT)`
|
150
160
|
|
151
|
-
If
|
152
|
-
|
153
|
-
them, or use the new `helpers` directive to define functions that will be
|
154
|
-
available to all actions.
|
161
|
+
If your old runfiles trap the `Interrupt` signal, there is no longer a need to
|
162
|
+
do so, as it is trapped by default.
|
155
163
|
|
156
|
-
###
|
164
|
+
### Colsole is included
|
157
165
|
|
158
|
-
If your
|
159
|
-
do
|
166
|
+
If your runfiles `required` and `include` Colsole, there is no longer a need to
|
167
|
+
do it. Colsole is bundled and available in actions.
|
160
168
|
|
161
|
-
###
|
169
|
+
### Long flags before short flags
|
162
170
|
|
163
|
-
|
164
|
-
|
171
|
+
This is a cosmetic change for consistency. All generated output shows long flags
|
172
|
+
before short flags `--force, -f` instead of `-f, --force`. Update your custom
|
173
|
+
`usage` directives accordingly.
|
165
174
|
|
166
|
-
###
|
175
|
+
### Examples no longer add implicit 'run'
|
167
176
|
|
168
|
-
|
169
|
-
|
170
|
-
|
177
|
+
If you were using the `example` directive, it will no longer add the initial
|
178
|
+
`run` in front of your examples. Add it yourself. This is intended to allow
|
179
|
+
providing more elaborate examples.
|
171
180
|
|
172
|
-
###
|
181
|
+
### RunfileTasks
|
173
182
|
|
174
|
-
|
175
|
-
|
176
|
-
providing more elaborate examples.
|
183
|
+
The `RunfileTasks` gem is also released as a pre-release, if you are using it
|
184
|
+
make sure to install the latest release candidate.
|
177
185
|
|
178
|
-
|
186
|
+
</details>
|
179
187
|
|
180
|
-
The `RunfileTasks` gem is also released as a pre-release, if you are using it
|
181
|
-
make sure to install the latest release candidate.
|
182
188
|
|
183
189
|
## Contributing / Support
|
184
190
|
|
data/lib/runfile/action.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Runfile
|
2
2
|
# Represents a single action inside a {Userfile} and executes its block
|
3
3
|
# on demand. Properties of this class are populated by the {DSL} module when
|
4
|
-
#
|
4
|
+
# the runfile is executed.
|
5
5
|
class Action
|
6
6
|
include Inspectable
|
7
7
|
|
@@ -26,7 +26,7 @@ module Runfile
|
|
26
26
|
|
27
27
|
instance_eval do
|
28
28
|
host.helpers.each { |b| b.call args }
|
29
|
-
block.call args
|
29
|
+
block.call args if block
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -34,10 +34,6 @@ module Runfile
|
|
34
34
|
@name = value&.to_s
|
35
35
|
end
|
36
36
|
|
37
|
-
def names
|
38
|
-
name ? [name, shortcut].compact : ['(default)']
|
39
|
-
end
|
40
|
-
|
41
37
|
def prefix
|
42
38
|
host&.full_name
|
43
39
|
end
|
@@ -58,6 +54,12 @@ module Runfile
|
|
58
54
|
@usages ||= []
|
59
55
|
end
|
60
56
|
|
57
|
+
private
|
58
|
+
|
59
|
+
def names
|
60
|
+
name.empty? ? [] : [name, shortcut].compact
|
61
|
+
end
|
62
|
+
|
61
63
|
def validate_context
|
62
64
|
host.required_contexts.each do |varname, default|
|
63
65
|
next if host.context[varname]
|
data/lib/runfile/concerns/dsl.rb
CHANGED
@@ -2,8 +2,6 @@ module Runfile
|
|
2
2
|
module DSL
|
3
3
|
# Commands
|
4
4
|
|
5
|
-
attr_reader :default_action
|
6
|
-
|
7
5
|
def action(name = nil, shortcut = nil, &block)
|
8
6
|
current_action.block = block
|
9
7
|
current_action.name = name.to_s
|
@@ -123,7 +121,6 @@ module Runfile
|
|
123
121
|
def finalize_current_action(name)
|
124
122
|
key = name.empty? ? :default : name
|
125
123
|
actions[key] = current_action
|
126
|
-
@default_action = current_action unless name
|
127
124
|
@current_action = nil
|
128
125
|
end
|
129
126
|
|
data/lib/runfile/exceptions.rb
CHANGED
data/lib/runfile/gem_finder.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Runfile
|
2
2
|
# Finds the path of an installed or bundled gem
|
3
|
-
# Adapted from Rubocop
|
3
|
+
# Adapted from [Rubocop](https://github.com/rubocop/rubocop/blob/master/lib/rubocop/config_loader_resolver.rb#L268)
|
4
4
|
class GemFinder
|
5
5
|
class << self
|
6
6
|
def find(gem_name, file = nil)
|
data/lib/runfile/runner.rb
CHANGED
@@ -11,9 +11,11 @@ module Runfile
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def call_docopt(docopt, version: nil, argv: nil)
|
14
|
-
|
15
|
-
rescue
|
14
|
+
DocoptNG.docopt docopt, argv: argv, version: version
|
15
|
+
rescue DocoptNG::Exit => e
|
16
16
|
raise ExitWithUsage, e.message
|
17
|
+
rescue DocoptNG::DocoptLanguageError => e
|
18
|
+
raise DocoptError, "There is an error in your runfile:\nnb`#{e.message}`"
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/lib/runfile/userfile.rb
CHANGED
@@ -77,9 +77,11 @@ module Runfile
|
|
77
77
|
|
78
78
|
def run(argv = [])
|
79
79
|
eval_code
|
80
|
-
argv = transform_argv argv if argv.any?
|
81
80
|
|
82
|
-
|
81
|
+
if argv.any?
|
82
|
+
argv = expand_shortcuts argv
|
83
|
+
found_guest = find_guest argv
|
84
|
+
end
|
83
85
|
|
84
86
|
if found_guest
|
85
87
|
found_guest.run argv
|
@@ -128,9 +130,19 @@ module Runfile
|
|
128
130
|
exit_code if exit_code.is_a? Integer
|
129
131
|
end
|
130
132
|
|
131
|
-
|
133
|
+
# Shortcuts will always appear after the name, so we split argv to
|
134
|
+
# name (array), shortcut wannabe (string), rest of the args (array).
|
135
|
+
# Then, if the shortcut wannabe is a match, we stitch the new argv back
|
136
|
+
# together, with its expansion.
|
137
|
+
def expand_shortcuts(argv)
|
138
|
+
size = id.size
|
139
|
+
|
140
|
+
p1 = argv[0...size]
|
141
|
+
p2 = argv[size]
|
142
|
+
p3 = argv[(size + 1)..]
|
143
|
+
|
132
144
|
shortcuts.each do |from, to|
|
133
|
-
return Shellwords.split(to) +
|
145
|
+
return p1 + Shellwords.split(to) + p3 if from == p2
|
134
146
|
end
|
135
147
|
|
136
148
|
argv
|
data/lib/runfile/version.rb
CHANGED
data/lib/runfile.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: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2023-
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -31,19 +31,19 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: docopt_ng
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0.
|
39
|
+
version: '0.7'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0.
|
46
|
+
version: '0.7'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: gtx
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,11 +144,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '2.7'
|
145
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- - "
|
147
|
+
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
149
|
+
version: '0'
|
150
150
|
requirements: []
|
151
|
-
rubygems_version: 3.4.
|
151
|
+
rubygems_version: 3.4.6
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Local command line for your projects
|