runfile 1.0.0 → 1.0.1

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: 97b62f3eec29bfcf7295e6d6da2f08b8461e9957f1d85296ab1831666d841f9e
4
- data.tar.gz: 5f2b029e59be9181f05abf5b45448bd1bf57527df33e8a5431c445b106c633e1
3
+ metadata.gz: b5a340ad5324cc9b24104fc460c171300cc2ab9690bb8bdfa2b38442b3ddf81a
4
+ data.tar.gz: e3f0fe2e7c4ba4fca9058d10f5caffc2daa76d5f0810aa5a63d646d2a23347d4
5
5
  SHA512:
6
- metadata.gz: 7ea4e40d8cca826236c906dd6d8430f6a5ba1d2f317babce072f6034cefa7e9bb439f6582dc4e4fffec017cbaf78e93ef5785c5578a6d13743d9910a8f62bc3f
7
- data.tar.gz: 42f2904c17a98672d2291808b7adde081207f083ab200a8a6ff01990a87aaf9b62554a4b914807363481d9ba59faadfdc57d0cdcf00820df8a3f9eff457be61b
6
+ metadata.gz: 0f94f10d4feda0300878584b68c1af769bc1a81392ee52f7716d89d0d7fe376cf9d20cc2cbb8bc0ef35d5574b469de038df67e99dbaa0a077ca4fed7a7cb548c
7
+ data.tar.gz: 5983f010e720484acdb6b013248c32f4ed104180e7fc05218c93abfaf1a3eea7775b95e7e6e7cbe2c0871316056fe4d99c27b7e1b93b13524782015199a66a8a
data/README.md CHANGED
@@ -125,8 +125,8 @@ Note that the current user guide is for the stable version 0.12.0.
125
125
  ## Breaking Changes in 1.0.0
126
126
 
127
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 [this Pull Request]
129
- (https://github.com/DannyBen/runfile/pull/50).
128
+ some breaking changes. You can read more about them in
129
+ [this Pull Request](https://github.com/DannyBen/runfile/pull/50).
130
130
 
131
131
  ### Upgrading to 1.0.0
132
132
 
@@ -11,10 +11,10 @@ module Runfile
11
11
  private
12
12
 
13
13
  def call_docopt(docopt, version: nil, argv: nil)
14
- Docopt.docopt docopt, argv: argv, version: version
15
- rescue Docopt::Exit => e
14
+ DocoptNG.docopt docopt, argv: argv, version: version
15
+ rescue DocoptNG::Exit => e
16
16
  raise ExitWithUsage, e.message
17
- rescue Docopt::DocoptLanguageError => e
17
+ rescue DocoptNG::DocoptLanguageError => e
18
18
  raise DocoptError, "There is an error in your runfile:\nnb`#{e.message}`"
19
19
  end
20
20
  end
@@ -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
- found_guest = find_guest argv
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
- def transform_argv(argv)
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) + argv[1..] if from == argv[0]
145
+ return p1 + Shellwords.split(to) + p3 if from == p2
134
146
  end
135
147
 
136
148
  argv
@@ -1,3 +1,3 @@
1
1
  module Runfile
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
data/lib/runfile.rb CHANGED
@@ -1,13 +1,8 @@
1
1
  require 'gtx'
2
- require 'docopt'
2
+ require 'docopt_ng'
3
3
  require 'colsole'
4
4
  require 'requires'
5
5
 
6
6
  requires 'runfile/exceptions'
7
7
  requires 'runfile/concerns'
8
8
  requires 'runfile'
9
-
10
- if ENV['BYEBUG']
11
- require 'byebug'
12
- require 'lp'
13
- 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: 1.0.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-02-01 00:00:00.000000000 Z
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: docopt
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.6'
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.6'
46
+ version: '0.7'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: gtx
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.4.5
151
+ rubygems_version: 3.4.6
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Local command line for your projects