runfile 1.0.0.rc1 → 1.0.0.rc3

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: b399f5dddc730408a835c29507af0b23d80be1ce6452c90d0c26d0d0acc577e7
4
- data.tar.gz: 27211f7110e22ca49317d893952d7af82bdd774879782335185f0421e74f864b
3
+ metadata.gz: 87fc70007827b06c5dc191a36501383e7cbbff057ab8b237e4fd1c6ecc1cc359
4
+ data.tar.gz: 63a028d2937711589b69f73003ddc367326fd0dc2d4decfad10e29e3b1d44078
5
5
  SHA512:
6
- metadata.gz: eaf0546be8eed23eeb6af18789a83e4b4eaa5514b044b41efb7a7a401da8465986a05bfcc5ec0930b0292edf4ea1830d2c78d0014808b59d5cf2f7c25fd3eb6d
7
- data.tar.gz: 7eb9ba751139e0a83106cf7a5c0ff933b51ebba6cdbd63ee32f7ddf34be249b9804f6fb007e303cb3e225cb3cedf04ed9418a7e6856cb94165208ee3e5e672c2
6
+ metadata.gz: ebdb28b94a76ad187975256fb7e3ab9d423e3b86af833f20b52d91e74886b4b03fd2a8849bdf1f50cd97c26978742f42a3522f375bd3d6567f5bb46c675b9ac2
7
+ data.tar.gz: fd87911f07745dff40c82bb8c4245cf309eae294799dbee320521c7d38b50a0c9575d9ad15fde44974c18639c05c3223712cf517389c149e6a9bd97020344b02
data/README.md CHANGED
@@ -29,7 +29,8 @@ command line "toolbelt" for your projects, you can use it regardless.
29
29
  ## Pre-release Notice
30
30
 
31
31
  Note that this README describes the not yet released 1.0.0 version.
32
- See https://bashly.dannyb.co/ for the stable release documentation.
32
+ See [runfile.dannyb.co](https://runfile.dannyb.co/) for the stable release
33
+ documentation.
33
34
 
34
35
  During the pre-release phase, the `run` executable is called `runn` instead,
35
36
  to allow running both the stable and pre-release version side by side.
@@ -137,7 +138,7 @@ Request](https://github.com/DannyBen/runfile/pull/50).
137
138
 
138
139
  ### Upgrading to 1.0.0
139
140
 
140
- ### No more `.runfile.yml` config
141
+ ### No more `.runfile` config
141
142
 
142
143
  If you have used the multi-runfile config file, this no longer exists.
143
144
  Use a standard `runfile` instead, along with the `import` directive.
@@ -148,6 +149,13 @@ If you have used the `action :global do` notation, this is replaced with the
148
149
  simpler use `action do` instead. Also, there is no more need for
149
150
  empty `usage ''`, just delete it if you have it in your runfiles.
150
151
 
152
+ ### No more `execute` directive
153
+
154
+ If you have used it to cross-call other actions, it is no longer available. As
155
+ an alternative, you can define common code in separate classes and `require`
156
+ them, or use the new `helpers` directive to define functions that will be
157
+ available to all actions.
158
+
151
159
  ### No more need for `trap(:INT)`
152
160
 
153
161
  If your old runfiles trap the `Interrupt` signal, there i no longer a need to
@@ -166,7 +174,8 @@ before short flags `--force, -f` instead of `-f, --force`. Update your custom
166
174
 
167
175
  ### RunfileTasks
168
176
 
169
- The `RunfileTasks` gem is not yet compatible. It will be later on.
177
+ The `RunfileTasks` gem is also released as a pre-release, if you are using it
178
+ make sure to install the latest release candidate.
170
179
 
171
180
  ## Contributing / Support
172
181
 
@@ -1,5 +1,7 @@
1
1
  title 'Default action and other actions'
2
2
 
3
+ import 'server'
4
+
3
5
  # $ run : will execute this block instead of showing usage
4
6
  action do
5
7
  say 'Running DEFAULT action'
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+
3
+ # Define helper methods
4
+ helpers do
5
+ def files
6
+ Dir['*'].sort
7
+ end
8
+ end
9
+
10
+ # $ run ls : can call helper methods
11
+ help 'Show files'
12
+ usage 'ls [--json]'
13
+ option '--json, -j', 'Output in JSON format'
14
+ action :ls do |args|
15
+ if args['--json']
16
+ puts files.to_json
17
+ else
18
+ puts files.join("\n")
19
+ end
20
+ end
@@ -3,5 +3,6 @@ option '--continue, -c', 'Continue testing'
3
3
  option '--failed, -f', 'Retest failed specs'
4
4
  action do |args|
5
5
  say 'spec action'
6
+ p context
6
7
  p args
7
8
  end
@@ -2,7 +2,7 @@ title 'Importing other funfiles'
2
2
  summary 'Reference other runfiles to blend them seamlessly as one command line interface'
3
3
 
4
4
  import 'tasks/*'
5
- import 'more_tasks/spec'
5
+ import 'more_tasks/spec', anything: 'Context Values'
6
6
 
7
7
  usage 'say MESSAGE'
8
8
  action 'say' do |args|
@@ -1,6 +1,7 @@
1
1
  summary 'Server management commands'
2
2
 
3
3
  action 'start' do |_args|
4
+ say "Context: #{context[:anything]}"
4
5
  say 'g`Starting server`'
5
6
  end
6
7
 
@@ -1,6 +1,8 @@
1
1
  title 'Multiple runfiles'
2
2
  summary 'Named runfiles in this directory will be blended seamlessly'
3
3
 
4
+ import 'server'
5
+
4
6
  help 'Say something'
5
7
  usage 'say MESSAGE [options]'
6
8
  option '--color, -c CODE', 'One letter color code [default: g]'
@@ -0,0 +1,4 @@
1
+ help 'Deploy to production'
2
+ action 'production' do
3
+ say 'Deploying to production'
4
+ end
@@ -0,0 +1,9 @@
1
+ title 'Primary Runfile (Rootfile)'
2
+
3
+ # import server.runfile
4
+ import 'server'
5
+
6
+ help 'Say hello'
7
+ action :welcome do
8
+ say 'Welcome to Runfile'
9
+ end
@@ -0,0 +1,15 @@
1
+ title 'Server commands'
2
+ summary 'Manage all the servers'
3
+
4
+ # Import all the runfiles in the deploy folder
5
+ import 'deploy/*'
6
+
7
+ help 'Build server'
8
+ action :build do
9
+ say 'Building...'
10
+ end
11
+
12
+ help 'Start server'
13
+ action :start do
14
+ say 'Server starting...'
15
+ end
@@ -0,0 +1,7 @@
1
+ title 'DevOps Toolbox'
2
+
3
+ import 'server', image: 'my-rails-app', allow_deploy: true
4
+
5
+ action 'ping' do
6
+ say 'PONG'
7
+ end
@@ -0,0 +1,25 @@
1
+ title 'Server commands'
2
+ summary 'Build and manage all the servers'
3
+
4
+ # Declare that we need three variables in the `import` directive
5
+ # One mandatory (:image) and two with a default fallback values
6
+ require_context :image
7
+ require_context :allow_deploy, default: false
8
+ require_context :env, default: 'development'
9
+
10
+ # $ run server : default command
11
+ action do |args|
12
+ say 'g`Context`:'
13
+ p context
14
+ say 'g`Args`:'
15
+ p args
16
+ end
17
+
18
+ help 'Deploy to production'
19
+ action 'deploy' do
20
+ if context[:allow_deploy]
21
+ say 'DEPLOYING'
22
+ else
23
+ say! 'r`Deployment not allowed`'
24
+ end
25
+ end
@@ -6,42 +6,60 @@ module Runfile
6
6
  include Inspectable
7
7
 
8
8
  attr_reader :name, :shortcut
9
- attr_accessor :block, :help, :prefix
9
+ attr_accessor :block, :help, :host
10
10
 
11
- def run(args = {})
12
- block.call args
11
+ def full_name
12
+ @full_name ||= if shortcut
13
+ "#{prefix} (#{name} | #{shortcut})".strip
14
+ else
15
+ "#{prefix} #{name}".strip
16
+ end
13
17
  end
14
18
 
15
- def inspectable
16
- { name: name, prefix: prefix, shortcut: shortcut }
19
+ def implicit_usages
20
+ usages.empty? ? [full_name] : usages
17
21
  end
18
22
 
19
- def name=(value)
20
- @name = value&.to_s
23
+ def inspectable
24
+ { name: name, prefix: prefix, 'host.path': host&.path }
21
25
  end
22
26
 
23
- def shortcut=(value)
24
- @shortcut = value&.to_s
25
- end
27
+ def run(args = {})
28
+ validate_context
26
29
 
27
- def full_name
28
- @full_name ||= if shortcut
29
- "#{prefix} (#{name} | #{shortcut})".strip
30
- else
31
- "#{prefix} #{name}".strip
30
+ instance_eval do
31
+ host.helpers.each { |b| b.call args }
32
+ block.call args
32
33
  end
33
34
  end
34
35
 
36
+ def name=(value)
37
+ @name = value&.to_s
38
+ end
39
+
35
40
  def names
36
41
  name ? [name, shortcut].compact : ['(default)']
37
42
  end
38
43
 
39
- def implicit_usages
40
- usages.empty? ? [full_name] : usages
44
+ def prefix
45
+ host&.full_name
46
+ end
47
+
48
+ def shortcut=(value)
49
+ @shortcut = value&.to_s
41
50
  end
42
51
 
43
52
  def usages
44
53
  @usages ||= []
45
54
  end
55
+
56
+ def validate_context
57
+ host.required_contexts.each do |varname, default|
58
+ next if host.context[varname]
59
+ raise UserError, "Need #{varname}" if default.nil?
60
+
61
+ host.context[varname] = default
62
+ end
63
+ end
46
64
  end
47
65
  end
@@ -6,19 +6,10 @@ module Runfile
6
6
 
7
7
  def action(name = nil, shortcut = nil, &block)
8
8
  current_action.block = block
9
- current_action.name = name
10
- current_action.shortcut = shortcut if shortcut
11
- current_action.prefix = action_prefix if action_prefix
12
-
13
- # if default_action && name
14
- # raise SyntaxError, <<~ERROR
15
- # Cannot define action nub`#{name}` since a default action was already defined
16
- # ERROR
17
- # end
18
-
19
- actions[name || :default] = current_action
20
- @default_action = current_action unless name
21
- @current_action = nil
9
+ current_action.name = name.to_s
10
+ current_action.shortcut = shortcut.to_s if shortcut
11
+ current_action.host = self
12
+ finalize_current_action name.to_s
22
13
  end
23
14
 
24
15
  def env_var(name, help)
@@ -33,21 +24,20 @@ module Runfile
33
24
  current_action.help = message
34
25
  end
35
26
 
36
- def import(pathspec)
37
- imports.push pathspec
27
+ def helpers(&block)
28
+ helper_blocks.push block if block
29
+ helper_blocks
38
30
  end
39
31
 
40
- def import_gem(gem_name, runfile_path, context = nil)
41
- if context && !context.is_a?(Hash)
42
- raise SyntaxError, <<~ERROR
43
- The third argument to nub`import_gem` must be a hash
44
- got rb`#{context.inspect}`
45
- ERROR
46
- end
32
+ def import(pathspec, context = nil)
33
+ imports[pathspec] = context
34
+ end
47
35
 
48
- path = GemFinder.find gem_name, runfile_path
49
- imports.push path
50
- contexts[runfile_path] = context if context
36
+ def import_gem(pathspec, context = nil)
37
+ gem_name, glob = pathspec.split('/', 2)
38
+ glob ||= '*'
39
+ path = GemFinder.find gem_name, glob
40
+ imports[path] = context
51
41
  end
52
42
 
53
43
  def option(name, help)
@@ -58,8 +48,16 @@ module Runfile
58
48
  params[name] = help
59
49
  end
60
50
 
51
+ def require_context(varname, default: nil)
52
+ required_contexts[varname] = default
53
+ end
54
+
55
+ def required_contexts
56
+ @required_contexts ||= {}
57
+ end
58
+
61
59
  def shortcut(name)
62
- current_action.shortcut = name
60
+ current_action.shortcut = name.to_s
63
61
  end
64
62
 
65
63
  def summary(text = nil)
@@ -75,7 +73,7 @@ module Runfile
75
73
  end
76
74
 
77
75
  def usage(message)
78
- message = "#{action_prefix} #{message}" if action_prefix
76
+ message = "#{name} #{message}" if name
79
77
  current_action.usages.push message
80
78
  end
81
79
 
@@ -85,20 +83,8 @@ module Runfile
85
83
  @version = text
86
84
  end
87
85
 
88
- def execute(command_line)
89
- run Shellwords.split(command_line)
90
- end
91
-
92
86
  # Evaluation Artifacts
93
87
 
94
- def action_prefix
95
- nil
96
- end
97
-
98
- def contexts
99
- @contexts ||= {}
100
- end
101
-
102
88
  def actions
103
89
  @actions ||= {}
104
90
  end
@@ -115,16 +101,27 @@ module Runfile
115
101
  @examples ||= []
116
102
  end
117
103
 
104
+ def helper_blocks
105
+ @helper_blocks ||= []
106
+ end
107
+
118
108
  def options
119
109
  @options ||= {}
120
110
  end
121
111
 
122
112
  def imports
123
- @imports ||= []
113
+ @imports ||= {}
124
114
  end
125
115
 
126
116
  private
127
117
 
118
+ def finalize_current_action(name)
119
+ key = name.empty? ? :default : name
120
+ actions[key] = current_action
121
+ @default_action = current_action unless name
122
+ @current_action = nil
123
+ end
124
+
128
125
  def current_action
129
126
  @current_action ||= Action.new
130
127
  end
@@ -11,12 +11,16 @@ module Runfile
11
11
  @argv = argv
12
12
  end
13
13
 
14
+ def handler
15
+ rootfile || Initiator.new
16
+ end
17
+
14
18
  def inspectable
15
19
  { argv: argv }
16
20
  end
17
21
 
18
22
  def run
19
- meta.handler(argv).run argv
23
+ handler.run argv
20
24
  end
21
25
 
22
26
  def run!
@@ -25,7 +29,7 @@ module Runfile
25
29
  say e.message
26
30
  1
27
31
  rescue Runfile::UserError => e
28
- puts e.backtrace.reverse if ENV['DEBUG']
32
+ allow_debug e
29
33
  say! "mib` #{e.class} `"
30
34
  say! e.message
31
35
  1
@@ -33,18 +37,30 @@ module Runfile
33
37
  say! 'm`Goodbye`', replace: true
34
38
  1
35
39
  rescue => e
36
- puts e.backtrace.reverse if ENV['DEBUG']
40
+ allow_debug e
37
41
  origin = e.backtrace_locations.first
38
42
  location = "#{origin.path}:#{origin.lineno}"
39
43
  say! "rib` #{e.class} ` in nu`#{location}`"
40
44
  say! e.message
45
+ say! "\nPrefix with nu`DEBUG=1` for full backtrace" unless ENV['DEBUG']
41
46
  1
42
47
  end
43
48
 
44
49
  private
45
50
 
46
- def meta
47
- @meta ||= Meta.new
51
+ def allow_debug(e)
52
+ return unless ENV['DEBUG']
53
+
54
+ say! e.backtrace.reverse.join("\n")
55
+ say! '---'
56
+ end
57
+
58
+ def rootfile
59
+ if File.exist? 'runfile'
60
+ Userfile.new 'runfile'
61
+ elsif File.exist? 'Runfile'
62
+ Userfile.new 'Runfile'
63
+ end
48
64
  end
49
65
  end
50
66
  end
@@ -46,10 +46,10 @@ module Runfile
46
46
 
47
47
  def create_example(name)
48
48
  dir = "#{examples_dir}/#{name}"
49
- files = Dir["#{dir}/{runfile,*.runfile,*.rb}"]
50
- raise UserError, "No such example: nu`#{name}`" if files.empty?
49
+ raise UserError, "No such example: nu`#{name}`" unless Dir.exist? dir
51
50
 
52
- files.each { |file| safe_copy file }
51
+ files = Dir.chdir(dir) { Dir['**/{runfile,*.runfile,*.rb}'] }.sort
52
+ files.each { |file| safe_copy dir, file }
53
53
  say_tip
54
54
  end
55
55
 
@@ -59,19 +59,22 @@ module Runfile
59
59
  say 'Delete the copied files to go back to the initial state'
60
60
  end
61
61
 
62
- def safe_copy(file)
63
- target = File.basename file
64
- # This will never happen since if there is a runfile, the initiator will
65
- # not be called. Nonetheless, keep it for safety
66
- return if File.exist? target
62
+ def safe_copy(source_dir, target_file)
63
+ source_file = "#{source_dir}/#{target_file}"
67
64
 
68
- FileUtils.cp file, '.'
69
- say "Copied g`#{target}`"
65
+ if File.exist? target_file
66
+ say "r`Skipped #{target_file}` (exists)"
67
+ return
68
+ end
69
+
70
+ FileUtils.mkdir_p File.dirname(target_file)
71
+ FileUtils.cp source_file, target_file
72
+ say "Copied g`#{target_file}`"
70
73
  end
71
74
 
72
75
  def examples
73
76
  @examples ||= Dir["#{examples_dir}/*"]
74
- .select { |f| File.directory? f }
77
+ .select { |f| File.directory? f }
75
78
  .map { |f| File.basename f }
76
79
  .sort
77
80
  end
@@ -7,39 +7,43 @@ module Runfile
7
7
  include Inspectable
8
8
  include DSL
9
9
 
10
- attr_reader :code, :name, :path
11
- attr_writer :context
12
- alias action_prefix name
13
-
14
- class << self
15
- def load_file(path)
16
- if masterfile? path
17
- name = nil
18
- else
19
- name = File.basename path, '.runfile'
20
- path = "#{path}.runfile" unless path.end_with? '.runfile'
21
- end
10
+ attr_reader :path, :host
11
+ attr_accessor :context
22
12
 
23
- code = File.read path
24
- new code, name: name, path: path
25
- end
13
+ def initialize(path, context: nil, host: nil)
14
+ @path = path
15
+ @host = host
16
+ @context = context || {}
17
+ end
26
18
 
27
- def masterfile?(path)
28
- Meta::MASTERFILE_NAMES.include? path
29
- end
19
+ def basename
20
+ @basename ||= File.basename(path, '.runfile')
30
21
  end
31
22
 
32
- def initialize(code = nil, name: nil, path: nil)
33
- @code = code
34
- @name = name
35
- @path = path
23
+ def code
24
+ @code ||= File.read(path)
25
+ end
36
26
 
37
- return unless @code
27
+ def eval_code
28
+ return if evaluated?
29
+
30
+ @evaluated = true
31
+ instance_eval code, path
32
+ end
38
33
 
39
- if path
40
- instance_eval @code, @path
34
+ def evaluated?
35
+ @evaluated
36
+ end
37
+
38
+ def full_name
39
+ id.join ' '
40
+ end
41
+
42
+ def id
43
+ if host
44
+ (host.id + [name]).compact
41
45
  else
42
- instance_eval @code
46
+ [name].compact
43
47
  end
44
48
  end
45
49
 
@@ -47,30 +51,38 @@ module Runfile
47
51
  { name: name, path: path }
48
52
  end
49
53
 
50
- def run(argv = [])
51
- found_delegate = delegate argv[0]
52
- if found_delegate
53
- found_delegate.run argv
54
- else
55
- run_local argv
56
- end
54
+ def name
55
+ @name ||= (rootfile? ? nil : basename.downcase)
57
56
  end
58
57
 
59
- def context
60
- @context ||= {}
58
+ def rootfile?
59
+ basename.casecmp? 'runfile'
61
60
  end
62
61
 
63
- def implicit_title
64
- title || name
62
+ def run(argv = [])
63
+ eval_code
64
+ found_guest = find_guest argv
65
+ if found_guest
66
+ found_guest.run argv
67
+ else
68
+ run_local argv
69
+ end
65
70
  end
66
71
 
67
- # Returns an array of actions that have help defined
68
72
  def commands
69
73
  actions.values.select(&:help)
70
74
  end
71
75
 
72
- def delegates
73
- @delegates ||= (name ? {} : meta.external_files)
76
+ def guests
77
+ @guests ||= begin
78
+ result = imports.map do |glob, context|
79
+ Dir.glob("#{glob}.runfile").sort.map do |guest_path|
80
+ Userfile.new guest_path, context: context, host: self
81
+ end
82
+ end
83
+
84
+ result.flatten
85
+ end
74
86
  end
75
87
 
76
88
  private
@@ -83,25 +95,30 @@ module Runfile
83
95
  actions[:default]
84
96
  end
85
97
 
98
+ def find_guest(argv)
99
+ guests.find do |guest|
100
+ guest_id_size = guest.id.size
101
+ next if guest_id_size.zero?
102
+
103
+ argv.first(guest_id_size) == guest.id
104
+ end
105
+ end
106
+
86
107
  def run_local(argv)
108
+ exit_code = nil
109
+ # This is here to allow guests to provide their own title/summary as
110
+ # the help message for the Commands block.
111
+ # TODO: Relatively costly. Consider alternatives.
112
+ guests.each(&:eval_code)
113
+
87
114
  Runner.run docopt, argv: argv, version: version do |args|
88
115
  action = find_action(args)
89
116
  raise ActionNotFound, 'Cannot find action. Is it properly defined?' unless action
90
117
 
91
- action.run args
118
+ exit_code = action.run args
92
119
  end
93
- end
94
-
95
- def delegate(name)
96
- return nil unless delegates.has_key? name
97
-
98
- result = delegates[name]
99
- result.context = contexts[name]
100
- result
101
- end
102
120
 
103
- def meta
104
- @meta ||= Meta.new
121
+ exit_code if exit_code.is_a? Integer
105
122
  end
106
123
 
107
124
  def docopt
@@ -1,3 +1,3 @@
1
1
  module Runfile
2
- VERSION = '1.0.0.rc1'
2
+ VERSION = '1.0.0.rc3'
3
3
  end
@@ -1,10 +1,10 @@
1
- if implicit_title
2
- = implicit_title
1
+ if title
2
+ = title
3
3
  >
4
4
  end
5
5
 
6
6
  if summary
7
- = implicit_title ? word_wrap(" #{summary}") : word_wrap(summary)
7
+ = title ? word_wrap(" #{summary}") : word_wrap(summary)
8
8
  >
9
9
  end
10
10
 
@@ -15,16 +15,15 @@ actions.each do |name, action|
15
15
  end
16
16
  end
17
17
 
18
- delegates.keys.each do |name|
19
- = " run #{name}"
20
- end
21
-
22
- if delegates.any?
23
- > run [COMMAND] (--help | -h)
24
- elsif name
25
- > run {{ name }} (--help | -h)
18
+ if guests.any?
19
+ guests.each do |userfile|
20
+ = " run #{userfile.full_name}"
21
+ end
22
+ > run [COMMAND] (--help | -h)
23
+ elsif full_name && !full_name.empty?
24
+ > run {{ full_name }} (--help | -h)
26
25
  else
27
- > run (--help | -h)
26
+ > run (--help | -h)
28
27
  end
29
28
 
30
29
  if version
@@ -32,7 +31,7 @@ if version
32
31
  end
33
32
  >
34
33
 
35
- if commands.any? || delegates.any?
34
+ if commands.any? || guests.any?
36
35
  > Commands:
37
36
  commands.each do |action|
38
37
  = " nb`#{action.names.join(', ')}`"
@@ -40,11 +39,11 @@ if commands.any? || delegates.any?
40
39
  >
41
40
  end
42
41
 
43
- delegates.each do |name, userfile|
42
+ guests.each do |userfile|
44
43
  summary = userfile.summary || userfile.title ||
45
- "Run nu`run #{name} --help` for more information"
44
+ "Run nu`run #{userfile.full_name} --help` for more information"
46
45
 
47
- = " nb`#{name}`"
46
+ = " nb`#{userfile.name}`"
48
47
  = word_wrap " #{summary}"
49
48
  >
50
49
  end
@@ -83,7 +82,6 @@ if env_vars.any?
83
82
  >
84
83
  end
85
84
 
86
-
87
85
  if examples.any?
88
86
  > Examples:
89
87
  examples.each do |text|
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.rc1
4
+ version: 1.0.0.rc3
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-01-25 00:00:00.000000000 Z
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
@@ -90,21 +90,22 @@ files:
90
90
  - examples/default-action-2/runfile
91
91
  - examples/default-action-2/server.runfile
92
92
  - examples/default-action/runfile
93
- - examples/different-name/runfile.rb
94
93
  - examples/example-multiline/runfile
95
94
  - examples/example/runfile
96
- - examples/execute/runfile
97
- - examples/execute/server.runfile
98
95
  - examples/full/runfile
96
+ - examples/helpers/runfile
99
97
  - examples/import/more_tasks/spec.runfile
100
98
  - examples/import/runfile
101
99
  - examples/import/tasks/server.runfile
102
100
  - examples/minimal/runfile
103
101
  - examples/multiple-runfiles/runfile
104
102
  - examples/multiple-runfiles/server.runfile
105
- - examples/named-only/deploy.runfile
106
- - examples/named-only/server.runfile
107
103
  - examples/naval-fate/runfile
104
+ - examples/nesting/deploy/deploy.runfile
105
+ - examples/nesting/runfile
106
+ - examples/nesting/server.runfile
107
+ - examples/require-context/runfile
108
+ - examples/require-context/server.runfile
108
109
  - examples/shortcut/runfile
109
110
  - lib/runfile.rb
110
111
  - lib/runfile/action.rb
@@ -115,7 +116,6 @@ files:
115
116
  - lib/runfile/exceptions.rb
116
117
  - lib/runfile/gem_finder.rb
117
118
  - lib/runfile/initiator.rb
118
- - lib/runfile/meta.rb
119
119
  - lib/runfile/runner.rb
120
120
  - lib/runfile/templates/runfile
121
121
  - lib/runfile/userfile.rb
@@ -1,8 +0,0 @@
1
- title 'Other name'
2
- summary 'The main runfile can be named "runfile", "Runfile" or "runfile.rb"'
3
-
4
- # $ run greet
5
- # $ run g
6
- action :greet, :g do
7
- say 'GREET'
8
- end
@@ -1,14 +0,0 @@
1
- title 'Execute other actions'
2
- summary 'Shows how to call other actions from within an action'
3
-
4
- # $ run greet
5
- # $ run g
6
- action :greet, :g do |_args|
7
- say 'GREET'
8
- end
9
-
10
- # $ run s
11
- help 'Shortcut to nu`server start`'
12
- action :s do
13
- execute 'server start'
14
- end
@@ -1,11 +0,0 @@
1
- # $ run server start
2
- # $ run server s
3
- action :start, :s do
4
- say 'START'
5
- end
6
-
7
- # $ run server stop
8
- # $ run server st
9
- action :stop, :st do
10
- say 'STOP'
11
- end
@@ -1,7 +0,0 @@
1
- title 'Deployment commands'
2
- summary 'With a default action'
3
-
4
- # $ run deploy
5
- action do
6
- say 'deploy command'
7
- end
@@ -1,11 +0,0 @@
1
- title 'Server commands'
2
-
3
- # $ run server stop
4
- action :stop do
5
- say 'stop server'
6
- end
7
-
8
- # $ run server start
9
- action :start do
10
- say 'start server'
11
- end
data/lib/runfile/meta.rb DELETED
@@ -1,65 +0,0 @@
1
- module Runfile
2
- # Holds meta information about the state of runfiles in a given directory
3
- class Meta
4
- include Inspectable
5
-
6
- MASTERFILE_NAMES = %w[runfile Runfile runfile.rb]
7
-
8
- def masterfile_path
9
- @masterfile_path ||= begin
10
- result = nil
11
-
12
- MASTERFILE_NAMES.each do |name|
13
- if File.exist? name
14
- result = name
15
- break
16
- end
17
- end
18
-
19
- result
20
- end
21
- end
22
-
23
- def handler(_argv = ARGV)
24
- masterfile || dummy || initiator
25
- end
26
-
27
- # If there are external files and no masterfile, we will use a dummy empty
28
- # runfile as a masterfile to serve as the access point to the named
29
- # runfiles
30
- def dummy
31
- return nil unless external_files.any?
32
-
33
- Userfile.new
34
- end
35
-
36
- def initiator
37
- Initiator.new
38
- end
39
-
40
- def masterfile
41
- return nil unless masterfile_path
42
-
43
- @masterfile ||= Userfile.load_file masterfile_path
44
- end
45
-
46
- # def title
47
- # masterfile&.title
48
- # end
49
-
50
- # def summary
51
- # masterfile&.summary
52
- # end
53
-
54
- def globs
55
- @globs ||= (masterfile ? ['*'] + masterfile.imports : ['*'])
56
- end
57
-
58
- def external_files
59
- @external_files ||= globs
60
- .map { |glob| Dir["#{glob}.runfile"].sort }
61
- .flatten
62
- .to_h { |file| [File.basename(file, '.runfile'), Userfile.load_file(file)] }
63
- end
64
- end
65
- end