miga-base 1.3.17.1 → 1.3.18.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 +4 -4
- data/lib/miga/cli/action/cmd.rb +57 -0
- data/lib/miga/cli/base.rb +1 -0
- data/lib/miga/cli/opt_helper.rb +1 -1
- data/lib/miga/cli.rb +11 -1
- data/lib/miga/common/system_call.rb +5 -2
- data/lib/miga/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf9ebc2ca06846d9b76c981c2a89896080690bc44d979ba28b4a9173f7386c7a
|
4
|
+
data.tar.gz: a156a4f0894f1988862b8daf296b916c80cf197eb36fb7c13c4698975403c35e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e1318553d24d93af467670754e86e5281c7418d4242ad11b56125889188fb7cde48a1858f20e1b07bab04a372c4aac718e04c005bdfadccf641c15cd7cf2ed
|
7
|
+
data.tar.gz: e584f1b4442a099fb16c4b0c07515b9332867c5b72438bae9e33467f9d0911c7bd4811a6861121482cada1b88f44aaec2efd6d2f668fa6a05c722c9fe56995bc
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# @package MiGA
|
2
|
+
# @license Artistic-2.0
|
3
|
+
|
4
|
+
require 'miga/cli/action'
|
5
|
+
|
6
|
+
class MiGA::Cli::Action::Cmd < MiGA::Cli::Action
|
7
|
+
def parse_cli
|
8
|
+
cli.expect_files = true
|
9
|
+
cli.files_label = 'CMD'
|
10
|
+
cli.defaults = {
|
11
|
+
raise: false, return: :status, source: :miga_env,
|
12
|
+
stdout: nil, stderr: nil, dry: false, show_cmd: false,
|
13
|
+
err2out: false
|
14
|
+
}
|
15
|
+
cli.parse do |opt|
|
16
|
+
opt.separator 'To separate command flags from MiGA flags, use --:'
|
17
|
+
opt.separator 'miga cmd --verbose -- rbm.rb --version'
|
18
|
+
opt.separator ''
|
19
|
+
opt.separator 'To run the command as is (no escaping), use single-quotes:'
|
20
|
+
opt.separator 'miga cmd \'echo $MIGA\''
|
21
|
+
opt.separator ''
|
22
|
+
opt.on(
|
23
|
+
'-o', '--stdout FILE',
|
24
|
+
'Save STDOUT to this file instead of displaying it'
|
25
|
+
) { |v| cli[:stdout] = v }
|
26
|
+
opt.on(
|
27
|
+
'-e', '--stderr FILE',
|
28
|
+
'Save STDERR to this file instead of displaying it'
|
29
|
+
) { |v| cli[:stderr] = v }
|
30
|
+
opt.on(
|
31
|
+
'--err2out',
|
32
|
+
'Combine STDERR and STDOUT into one single channel (STDOUT)'
|
33
|
+
) { |v| cli[:err2out] = v }
|
34
|
+
opt.on(
|
35
|
+
'--show-cmd',
|
36
|
+
'Show exact command being launched before running it'
|
37
|
+
) { |v| cli[:show_cmd] = v }
|
38
|
+
opt.on(
|
39
|
+
'--dry',
|
40
|
+
'Prepare the command but stop short of executing it',
|
41
|
+
'Useful in combination with --show-cmd; it always exits with code 1'
|
42
|
+
) { |v| cli[:dry] = v }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def perform
|
47
|
+
cli.files
|
48
|
+
cli.say 'Running command:'
|
49
|
+
cmd = cli.files.size == 1 ? cli.files[0] : cli.files
|
50
|
+
cli.say cmd
|
51
|
+
status = MiGA::MiGA.run_cmd(cmd, cli.to_h)
|
52
|
+
cli.say 'Exit status: %s' % status
|
53
|
+
unless status&.success?
|
54
|
+
exit(status.nil? ? 1 : status.exitstatus)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/miga/cli/base.rb
CHANGED
@@ -44,6 +44,7 @@ module MiGA::Cli::Base
|
|
44
44
|
date: 'Return the current date in standard MiGA format',
|
45
45
|
console: 'Open an IRB console with MiGA',
|
46
46
|
env: 'Shell code to load MiGA environment',
|
47
|
+
cmd: 'Run a shell command within the MiGA environment',
|
47
48
|
# Taxonomy
|
48
49
|
tax_set: 'Register taxonomic information for datasets',
|
49
50
|
tax_test: 'Return test of taxonomic distributions for query datasets',
|
data/lib/miga/cli/opt_helper.rb
CHANGED
@@ -9,7 +9,7 @@ module MiGA::Cli::OptHelper
|
|
9
9
|
usage = "Usage: miga #{action.name}"
|
10
10
|
usage += ' {operation}' if expect_operation
|
11
11
|
usage += ' [options]'
|
12
|
-
usage +=
|
12
|
+
usage += " {#{files_label || 'FILES'}...}" if expect_files
|
13
13
|
opt.banner = "\n#{task_description}\n\n#{usage}\n"
|
14
14
|
opt.separator ''
|
15
15
|
end
|
data/lib/miga/cli.rb
CHANGED
@@ -34,6 +34,10 @@ class MiGA::Cli < MiGA::MiGA
|
|
34
34
|
# If files are expected after the parameters, a boolean
|
35
35
|
attr_accessor :expect_files
|
36
36
|
|
37
|
+
##
|
38
|
+
# Label used in the usage instead of FILES if +#expect_files = true+
|
39
|
+
attr_accessor :files_label
|
40
|
+
|
37
41
|
##
|
38
42
|
# Files passed after all other options, if +#expect_files = true+
|
39
43
|
attr_accessor :files
|
@@ -145,7 +149,7 @@ class MiGA::Cli < MiGA::MiGA
|
|
145
149
|
##
|
146
150
|
# Set default values in the Hash +hsh+
|
147
151
|
def defaults=(hsh)
|
148
|
-
hsh.each { |k, v| @defaults[k] = v }
|
152
|
+
hsh.each { |k, v| @defaults[k.to_sym] = v }
|
149
153
|
end
|
150
154
|
|
151
155
|
##
|
@@ -161,6 +165,12 @@ class MiGA::Cli < MiGA::MiGA
|
|
161
165
|
@data[k.to_sym] = v
|
162
166
|
end
|
163
167
|
|
168
|
+
##
|
169
|
+
# Return parsed and default values as a hash
|
170
|
+
def to_h
|
171
|
+
@defaults.merge(@data)
|
172
|
+
end
|
173
|
+
|
164
174
|
##
|
165
175
|
# Redefine #action based on #task
|
166
176
|
def reset_action
|
@@ -18,7 +18,9 @@ module MiGA::Common::SystemCall
|
|
18
18
|
out_io, spawn_opts[:out] = IO.pipe if opts[:return] == :output
|
19
19
|
spawn_opts[:err] = [:child, :out] if opts[:err2out] && spawn_opts[:out]
|
20
20
|
opts[:source] = MiGA::MiGA.rc_path if opts[:source] == :miga
|
21
|
-
if opts[:source]
|
21
|
+
if opts[:source] == :miga_env
|
22
|
+
cmd = "eval \"$(#{File.join(root_path, 'bin', 'miga').shellescape} env)\" && #{cmd}"
|
23
|
+
elsif opts[:source] && File.exist?(opts[:source])
|
22
24
|
cmd = ". #{opts[:source].shellescape} && #{cmd}"
|
23
25
|
end
|
24
26
|
|
@@ -76,7 +78,8 @@ module MiGA::Common::SystemCall
|
|
76
78
|
# - err2out: Redirect STDERR to STDOUT
|
77
79
|
# - env: Environmental variables as a Hash, keys and values must be strings
|
78
80
|
# - source: A file to be sourced before running, or the Symbol +:miga+ to
|
79
|
-
# source the MiGA configuration file
|
81
|
+
# source the MiGA configuration file, or the Symbol +:miga_env+ to run
|
82
|
+
# `eval $(miga env)` beforehand instead
|
80
83
|
def run_cmd_opts(opts = {})
|
81
84
|
{
|
82
85
|
stdout: nil,
|
data/lib/miga/version.rb
CHANGED
@@ -12,7 +12,7 @@ module MiGA
|
|
12
12
|
# - String indicating release status:
|
13
13
|
# - rc* release candidate, not released as gem
|
14
14
|
# - [0-9]+ stable release, released as gem
|
15
|
-
VERSION = [1.3,
|
15
|
+
VERSION = [1.3, 18, 0].freeze
|
16
16
|
|
17
17
|
##
|
18
18
|
# Nickname for the current major.minor version.
|
@@ -20,7 +20,7 @@ module MiGA
|
|
20
20
|
|
21
21
|
##
|
22
22
|
# Date of the current gem relese.
|
23
|
-
VERSION_DATE = Date.new(2024, 7,
|
23
|
+
VERSION_DATE = Date.new(2024, 7, 12)
|
24
24
|
|
25
25
|
##
|
26
26
|
# References of MiGA
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miga-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis M. Rodriguez-R
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/miga/cli/action/browse/style.css
|
178
178
|
- lib/miga/cli/action/browse/summary.html
|
179
179
|
- lib/miga/cli/action/classify_wf.rb
|
180
|
+
- lib/miga/cli/action/cmd.rb
|
180
181
|
- lib/miga/cli/action/console.rb
|
181
182
|
- lib/miga/cli/action/daemon.rb
|
182
183
|
- lib/miga/cli/action/date.rb
|