runfile 1.0.0.rc2 → 1.0.0.rc3

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: 5ae2a7aefd3a25703d232d70e6857aeafe467772582a96202d371bfca748e1f7
4
- data.tar.gz: 32f39514ba7ffb8318c305278f55a397d2e686c7179cec0ff5899c5e6fd62871
3
+ metadata.gz: 87fc70007827b06c5dc191a36501383e7cbbff057ab8b237e4fd1c6ecc1cc359
4
+ data.tar.gz: 63a028d2937711589b69f73003ddc367326fd0dc2d4decfad10e29e3b1d44078
5
5
  SHA512:
6
- metadata.gz: 289c29cf9119ce944bc46c1c6067299454396b143721b5b5b0b6b03553bca3c805743656a13cb8f4757a77022e4294152254124d7f6dfea4803879ac4289690d
7
- data.tar.gz: 61afd4733813f4f3082765eae107295af324a446da8ccc5bc70959504c81aba0a161e286fc25ff0095b2fbff0c50b3a9fb76a8a21f992c6f5c620b1abd15b111
6
+ metadata.gz: ebdb28b94a76ad187975256fb7e3ab9d423e3b86af833f20b52d91e74886b4b03fd2a8849bdf1f50cd97c26978742f42a3522f375bd3d6567f5bb46c675b9ac2
7
+ data.tar.gz: fd87911f07745dff40c82bb8c4245cf309eae294799dbee320521c7d38b50a0c9575d9ad15fde44974c18639c05c3223712cf517389c149e6a9bd97020344b02
data/README.md CHANGED
@@ -138,7 +138,7 @@ Request](https://github.com/DannyBen/runfile/pull/50).
138
138
 
139
139
  ### Upgrading to 1.0.0
140
140
 
141
- ### No more `.runfile.yml` config
141
+ ### No more `.runfile` config
142
142
 
143
143
  If you have used the multi-runfile config file, this no longer exists.
144
144
  Use a standard `runfile` instead, along with the `import` directive.
@@ -149,6 +149,13 @@ If you have used the `action :global do` notation, this is replaced with the
149
149
  simpler use `action do` instead. Also, there is no more need for
150
150
  empty `usage ''`, just delete it if you have it in your runfiles.
151
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
+
152
159
  ### No more need for `trap(:INT)`
153
160
 
154
161
  If your old runfiles trap the `Interrupt` signal, there i no longer a need to
@@ -167,7 +174,8 @@ before short flags `--force, -f` instead of `-f, --force`. Update your custom
167
174
 
168
175
  ### RunfileTasks
169
176
 
170
- 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.
171
179
 
172
180
  ## Contributing / Support
173
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
@@ -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,13 +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
- actions[name || :default] = current_action
14
- @default_action = current_action unless name
15
- @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
16
13
  end
17
14
 
18
15
  def env_var(name, help)
@@ -27,6 +24,11 @@ module Runfile
27
24
  current_action.help = message
28
25
  end
29
26
 
27
+ def helpers(&block)
28
+ helper_blocks.push block if block
29
+ helper_blocks
30
+ end
31
+
30
32
  def import(pathspec, context = nil)
31
33
  imports[pathspec] = context
32
34
  end
@@ -46,8 +48,16 @@ module Runfile
46
48
  params[name] = help
47
49
  end
48
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
+
49
59
  def shortcut(name)
50
- current_action.shortcut = name
60
+ current_action.shortcut = name.to_s
51
61
  end
52
62
 
53
63
  def summary(text = nil)
@@ -63,7 +73,7 @@ module Runfile
63
73
  end
64
74
 
65
75
  def usage(message)
66
- message = "#{action_prefix} #{message}" if action_prefix
76
+ message = "#{name} #{message}" if name
67
77
  current_action.usages.push message
68
78
  end
69
79
 
@@ -73,16 +83,8 @@ module Runfile
73
83
  @version = text
74
84
  end
75
85
 
76
- def execute(command_line)
77
- run Shellwords.split(command_line)
78
- end
79
-
80
86
  # Evaluation Artifacts
81
87
 
82
- def action_prefix
83
- nil
84
- end
85
-
86
88
  def actions
87
89
  @actions ||= {}
88
90
  end
@@ -99,6 +101,10 @@ module Runfile
99
101
  @examples ||= []
100
102
  end
101
103
 
104
+ def helper_blocks
105
+ @helper_blocks ||= []
106
+ end
107
+
102
108
  def options
103
109
  @options ||= {}
104
110
  end
@@ -109,6 +115,13 @@ module Runfile
109
115
 
110
116
  private
111
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
+
112
125
  def current_action
113
126
  @current_action ||= Action.new
114
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,70 +7,82 @@ 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?
38
29
 
39
- if path
40
- instance_eval @code, @path
30
+ @evaluated = true
31
+ instance_eval code, path
32
+ end
33
+
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
 
46
50
  def inspectable
47
- { name: name, path: path, context: context }
51
+ { name: name, path: path }
48
52
  end
49
53
 
50
- def run(argv = [])
51
- found_delegate = delegates[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,17 +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
120
 
95
- def meta
96
- @meta ||= Meta.new
121
+ exit_code if exit_code.is_a? Integer
97
122
  end
98
123
 
99
124
  def docopt
@@ -1,3 +1,3 @@
1
1
  module Runfile
2
- VERSION = '1.0.0.rc2'
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.rc2
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-26 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 globs
47
- @globs ||= (masterfile ? ['*'] + masterfile.imports.keys : ['*'])
48
- end
49
-
50
- def external_files
51
- @external_files ||= begin
52
- result = []
53
- globs.each do |glob|
54
- Dir["#{glob}.runfile"].sort.each do |file|
55
- userfile = Userfile.load_file(file)
56
- userfile.context = masterfile.imports[glob] if masterfile
57
- result.push userfile
58
- end
59
- end
60
-
61
- result.to_h { |file| [file.name, file] }
62
- end
63
- end
64
- end
65
- end