asgard 0.6.1 → 0.6.2
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/CHANGELOG.md +68 -1
- data/README.md +1 -1
- data/lib/asgard/base/task_dsl.rb +14 -0
- data/lib/asgard/base.rb +10 -0
- data/lib/asgard/doctor/report.rb +3 -0
- data/lib/asgard/doctor/task_sections.rb +7 -6
- data/lib/asgard/jobs/commands.rb +19 -0
- data/lib/asgard/leading_flag.rb +7 -4
- data/lib/asgard/schedule/commands.rb +1 -1
- data/lib/asgard/schedule/declaration.rb +4 -2
- data/lib/asgard/schedule/launchd.rb +1 -1
- data/lib/asgard/schedule.rb +2 -2
- data/lib/asgard/version.rb +1 -1
- data/lib/asgard/watch/changes.rb +2 -2
- data/lib/asgard/watch/reporter.rb +2 -2
- data/lib/asgard/watch/worker.rb +6 -0
- data/lib/asgard.rb +28 -6
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d009f656e6d58b451c19ad7e9dde32c13a4e37c2943dace9f6afc018c17934d
|
|
4
|
+
data.tar.gz: a843940da659cf7e77912b32efe262547d2ac85e4ce09f9dd54dcb0104c65b19
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af6cf9020773314672e8dd93c1a39654fbae24fa519b049babf2843435b48a974052a651efb595066d14addc99cb31e0936f22f7630d20a1b3785a16593698d0
|
|
7
|
+
data.tar.gz: ef3058d0afc35d29007ce8e34bbead12669b06d08af83a1cd50865dc40cf5ff5a5639c69928d024af703ff33b006f5c8298e08d808ea02a311cece11ad2c0c8c
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.2] - 2026-11-18
|
|
11
|
+
|
|
12
|
+
A patch release of CLI fixes: leading `--debug` and `--verbose` in every
|
|
13
|
+
form, `TASK --help`, and clearer messages for an unknown option, a
|
|
14
|
+
mistyped `jobs` subcommand and a `default_task` that is not a task. No
|
|
15
|
+
`.loki` file needs to change, and nothing that worked in 0.6.1 breaks.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **An unknown leading option is named as an option**: `asgard --nope`
|
|
20
|
+
now says `asgard: unknown option '--nope'; see asgard help` instead of
|
|
21
|
+
`Could not find command "__nope".` Only the message changes; it still
|
|
22
|
+
exits 1, so this is not a breaking change.
|
|
23
|
+
- **A bad `schedule ... every:` says what it accepts and what it got**:
|
|
24
|
+
the message no longer suggests `3.minutes`, which fails without
|
|
25
|
+
ActiveSupport, and now ends with the value given, e.g. `got 90.0`.
|
|
26
|
+
([#46](https://github.com/MadBomber/asgard/issues/46))
|
|
27
|
+
- **`asgard TASK --help` shows the task's help**: `TASK --help` and
|
|
28
|
+
`TASK -h` now work like `asgard help TASK`, instead of running the task
|
|
29
|
+
with `--help` as its argument or failing with "was called with
|
|
30
|
+
arguments". ([#43](https://github.com/MadBomber/asgard/issues/43))
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **A leading `--debug` or `--verbose` keeps the list commands machine-wide**:
|
|
35
|
+
`asgard --debug jobs list`, `schedule list` and `watcher list` now run
|
|
36
|
+
from a directory with no `.loki` above it, instead of stopping with "no
|
|
37
|
+
.loki file found".
|
|
38
|
+
- **Every form of a leading `--debug` or `--verbose` runs the task named
|
|
39
|
+
after it**: `asgard --debug=true build`, `--no-debug` and `--skip-verbose`
|
|
40
|
+
now move behind the task name like a bare `--debug`, instead of running
|
|
41
|
+
the default task with `build` as its argument or printing its usage.
|
|
42
|
+
A leading flag also reaches a task defined without a `desc` or with
|
|
43
|
+
`hide: true`, and a task named with dashes (`deploy-app` for
|
|
44
|
+
`deploy_app`). ([#38](https://github.com/MadBomber/asgard/issues/38))
|
|
45
|
+
- **An empty word after a leading flag reaches the default task**:
|
|
46
|
+
`asgard --verbose ''` runs the default task with `""` as its argument,
|
|
47
|
+
as it did before 0.6.1, instead of failing as an ambiguous command that
|
|
48
|
+
listed the gem's internal `_jobs`, `_schedule` and `_watcher` names.
|
|
49
|
+
- **The README's opening callout renders as a note on GitHub**: it used
|
|
50
|
+
`[!INFO]`, which GitHub does not recognise, and now uses `[!NOTE]`.
|
|
51
|
+
([#45](https://github.com/MadBomber/asgard/issues/45))
|
|
52
|
+
- **The test suite passes with `RUBYOPT=-w` or `ASGARD_TRACE` set**: the
|
|
53
|
+
tests that run `bin/asgard` as a child process no longer pass on the
|
|
54
|
+
developer's trace setting or warning level.
|
|
55
|
+
([#48](https://github.com/MadBomber/asgard/issues/48))
|
|
56
|
+
- **`watcher.log` no longer opens with Ruby's experimental-Ractor warning**:
|
|
57
|
+
the watcher silences that one warning while it starts its workers, so
|
|
58
|
+
`watcher start` logs and `watcher run` output begin with real entries.
|
|
59
|
+
([#44](https://github.com/MadBomber/asgard/issues/44))
|
|
60
|
+
- **`--doctor` says why a task is hidden**: a task described with
|
|
61
|
+
`hide: true` is listed as `hidden (hide: true; not shown by help)`
|
|
62
|
+
instead of `hidden (no desc; ...)`, which now marks only desc-less tasks.
|
|
63
|
+
([#47](https://github.com/MadBomber/asgard/issues/47))
|
|
64
|
+
- **`--doctor` prints no colour codes when piped or with `NO_COLOR` set**:
|
|
65
|
+
it colours its lines only on a terminal, as the `list` tables do.
|
|
66
|
+
([#50](https://github.com/MadBomber/asgard/issues/50))
|
|
67
|
+
- **A `default_task` that names no task is reported as such**: plain
|
|
68
|
+
`asgard` (or `asgard --debug`) now says `asgard: default_task :nope (set
|
|
69
|
+
at .loki:2) is not a task` instead of `Could not find command "".`
|
|
70
|
+
([#51](https://github.com/MadBomber/asgard/issues/51))
|
|
71
|
+
- **A mistyped `jobs` subcommand is named**: `asgard jobs stpo api` now
|
|
72
|
+
says `Could not find command "stpo".` with a "Did you mean?" hint, as
|
|
73
|
+
`schedule` and `watcher` do, instead of reporting arguments to `jobs list`.
|
|
74
|
+
([#52](https://github.com/MadBomber/asgard/issues/52))
|
|
75
|
+
|
|
10
76
|
## [0.6.1] - 2026-11-14
|
|
11
77
|
|
|
12
78
|
Two changes can break a script that runs asgard: `--doctor` exits 1 when
|
|
@@ -553,7 +619,8 @@ reinstalled after.
|
|
|
553
619
|
- 100% test coverage enforced via SimpleCov (95% minimum threshold)
|
|
554
620
|
- Quality task in `.loki` runs flog after tests
|
|
555
621
|
|
|
556
|
-
[Unreleased]: https://github.com/MadBomber/asgard/compare/v0.6.
|
|
622
|
+
[Unreleased]: https://github.com/MadBomber/asgard/compare/v0.6.2...HEAD
|
|
623
|
+
[0.6.2]: https://github.com/MadBomber/asgard/compare/v0.6.1...v0.6.2
|
|
557
624
|
[0.6.1]: https://github.com/MadBomber/asgard/compare/v0.6.0...v0.6.1
|
|
558
625
|
[0.6.0]: https://github.com/MadBomber/asgard/compare/v0.5.1...v0.6.0
|
|
559
626
|
[0.5.1]: https://github.com/MadBomber/asgard/compare/v0.4.1...v0.5.1
|
data/README.md
CHANGED
data/lib/asgard/base/task_dsl.rb
CHANGED
|
@@ -65,6 +65,20 @@ module Asgard
|
|
|
65
65
|
end
|
|
66
66
|
super
|
|
67
67
|
end
|
|
68
|
+
|
|
69
|
+
# Thor runs the default task when the command line is empty or starts
|
|
70
|
+
# with an option it does not map. A default_task that names no task
|
|
71
|
+
# would then fail as `Could not find command "".`, so name it.
|
|
72
|
+
def check_default_task!(argv)
|
|
73
|
+
first = argv.first
|
|
74
|
+
return if first && (map.key?(first) || !first.start_with?("-"))
|
|
75
|
+
|
|
76
|
+
name = default_command.to_s
|
|
77
|
+
return if all_commands.key?(name.tr("-", "_"))
|
|
78
|
+
|
|
79
|
+
where = " (set at #{@_default_task_location.path}:#{@_default_task_location.lineno})" if @_default_task_location
|
|
80
|
+
raise Asgard::Error, "default_task :#{name}#{where} is not a task"
|
|
81
|
+
end
|
|
68
82
|
end
|
|
69
83
|
end
|
|
70
84
|
end
|
data/lib/asgard/base.rb
CHANGED
|
@@ -109,6 +109,12 @@ module Asgard
|
|
|
109
109
|
(Thor.private_method_defined?(method_name) && !Kernel.respond_to?(method_name))
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
+
# Whether +word+, given to help as a command name, is an option Thor
|
|
113
|
+
# did not recognise. Thor's own help flags (-h, --help) are not.
|
|
114
|
+
def unknown_option?(word)
|
|
115
|
+
word.to_s.start_with?("-") && !Thor::HELP_MAPPINGS.include?(word)
|
|
116
|
+
end
|
|
117
|
+
|
|
112
118
|
# The task `asgard help NAME` describes: a built-in group's mapped
|
|
113
119
|
# name ("jobs") is its registered subcommand ("_jobs"); anything else
|
|
114
120
|
# is NAME unchanged.
|
|
@@ -200,8 +206,12 @@ module Asgard
|
|
|
200
206
|
end
|
|
201
207
|
end
|
|
202
208
|
|
|
209
|
+
# Thor hands an unknown leading option (`asgard --nope`) to the default
|
|
210
|
+
# command, help, as a command name; name it as the option it is.
|
|
203
211
|
def help(command = nil, subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
|
|
204
212
|
klass = self.class
|
|
213
|
+
raise Asgard::Error, "unknown option '#{command}'; see asgard help" if klass.unknown_option?(command)
|
|
214
|
+
|
|
205
215
|
top_level = command.nil?
|
|
206
216
|
header_text = klass.header
|
|
207
217
|
footer_text = klass.footer
|
data/lib/asgard/doctor/report.rb
CHANGED
|
@@ -69,7 +69,10 @@ module Asgard
|
|
|
69
69
|
colorize(31, "#{errors} problem(s), #{warns} warning(s).")
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
# Coloured only on a terminal with NO_COLOR unset, as the list tables are.
|
|
72
73
|
def colorize(code, text)
|
|
74
|
+
return text unless $stdout.tty? && !ENV.key?("NO_COLOR")
|
|
75
|
+
|
|
73
76
|
"\e[#{code}m#{text}\e[0m"
|
|
74
77
|
end
|
|
75
78
|
end
|
|
@@ -7,12 +7,13 @@ module Asgard
|
|
|
7
7
|
# more than one recorded location (the each/each_gem class of bug) —
|
|
8
8
|
# earlier ones OVERRIDDEN (dead), the last one the active redefinition.
|
|
9
9
|
module TaskSections
|
|
10
|
-
# A hidden task
|
|
11
|
-
#
|
|
12
|
-
def self.with_hidden(status,
|
|
13
|
-
return status unless hidden
|
|
10
|
+
# A hidden task says so, after any override note, and says why: no
|
|
11
|
+
# desc, or a desc given hide: true.
|
|
12
|
+
def self.with_hidden(status, command)
|
|
13
|
+
return status unless command.hidden?
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
reason = command.description == Base.singleton_class::HIDDEN_DESC ? "no desc" : "hide: true"
|
|
16
|
+
[status, "hidden (#{reason}; not shown by help)"].compact.join("; ")
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
private
|
|
@@ -33,7 +34,7 @@ module Asgard
|
|
|
33
34
|
command = commands[name.to_s] or next
|
|
34
35
|
|
|
35
36
|
locations.each_with_index do |(file, line), idx|
|
|
36
|
-
file_map[file] << [name, line, TaskSections.with_hidden(task_status(locations, idx), command
|
|
37
|
+
file_map[file] << [name, line, TaskSections.with_hidden(task_status(locations, idx), command)]
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
file_map.each_value { |tasks| tasks.sort_by! { |t| t[1] } }
|
data/lib/asgard/jobs/commands.rb
CHANGED
|
@@ -43,6 +43,25 @@ module Asgard
|
|
|
43
43
|
|
|
44
44
|
# The argv that follows a log the way `tail -f` does, from the top.
|
|
45
45
|
def tail_argv(path) = ["tail", "-n", "+1", "-f", path]
|
|
46
|
+
|
|
47
|
+
# Whether +word+ is a typed subcommand that names none: not an
|
|
48
|
+
# option, a mapped name, a command or an abbreviation of one.
|
|
49
|
+
def undefined_subcommand?(word)
|
|
50
|
+
return false if word.nil? || word.start_with?("-")
|
|
51
|
+
|
|
52
|
+
!(map.key?(word) || all_commands.key?(word.tr("-", "_")) || find_command_possibilities(word).any?)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
protected
|
|
56
|
+
|
|
57
|
+
# Thor hands a word that names no subcommand to the default command,
|
|
58
|
+
# list, as its argument; list takes none, so name the word instead,
|
|
59
|
+
# as `schedule` and `watcher` do.
|
|
60
|
+
def dispatch(meth, given_args, given_opts, config)
|
|
61
|
+
word = meth || given_args.first
|
|
62
|
+
handle_no_command_error(word) if config[:invoked_via_subcommand] && undefined_subcommand?(word)
|
|
63
|
+
super
|
|
64
|
+
end
|
|
46
65
|
end
|
|
47
66
|
|
|
48
67
|
desc "tree", "Print a tree of the jobs subcommands", hide: true
|
data/lib/asgard/leading_flag.rb
CHANGED
|
@@ -9,15 +9,18 @@ module Asgard
|
|
|
9
9
|
def self.leading_flag?(argv, flag) = argv.take_while { |word| word.start_with?("-") }.include?(flag)
|
|
10
10
|
|
|
11
11
|
# The options that set a global for whatever task runs, so they read the
|
|
12
|
-
# same on either side of the task name
|
|
13
|
-
|
|
12
|
+
# same on either side of the task name: --debug and --verbose in every
|
|
13
|
+
# form Thor accepts after it (--debug=VALUE, --no-debug, --skip-debug).
|
|
14
|
+
GLOBAL_FLAG = /\A--(?:(?:debug|verbose)(?:=.*)?|(?:no|skip)-(?:debug|verbose))\z/
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
def self.global_flag?(word) = GLOBAL_FLAG.match?(word)
|
|
17
|
+
|
|
18
|
+
# +argv+ with the task name first: leading global flags move behind the
|
|
16
19
|
# word they precede when the block says that word names a task. Thor
|
|
17
20
|
# hands a command line that starts with an option to the default task,
|
|
18
21
|
# so without this `asgard --verbose build` never reaches `build`.
|
|
19
22
|
def self.task_first(argv)
|
|
20
|
-
flags = argv.take_while {
|
|
23
|
+
flags = argv.take_while { global_flag?(it) }
|
|
21
24
|
word = argv[flags.size]
|
|
22
25
|
return argv if flags.empty? || word.nil? || !yield(word)
|
|
23
26
|
|
|
@@ -52,7 +52,7 @@ module Asgard
|
|
|
52
52
|
|
|
53
53
|
def schedule_asgard = Schedule.which("asgard", ENV.fetch("PATH", nil)) || abort("schedule: asgard is not on PATH")
|
|
54
54
|
|
|
55
|
-
def schedule_summary(spec) = "#{Schedule.command_line(spec[:task], spec[:args])} (#{Schedule.describe(
|
|
55
|
+
def schedule_summary(spec) = "#{Schedule.command_line(spec[:task], spec[:args])} (#{Schedule.describe(spec)})"
|
|
56
56
|
|
|
57
57
|
# One `list` row for this project: its declaration (if still declared) plus live state.
|
|
58
58
|
def schedule_row(name)
|
|
@@ -95,10 +95,12 @@ module Asgard
|
|
|
95
95
|
if every
|
|
96
96
|
raise ArgumentError, "schedule :#{task} on: only applies to at: times; every: runs on every day" if on
|
|
97
97
|
|
|
98
|
+
given = every
|
|
98
99
|
every = seconds(every)
|
|
99
100
|
unless every&.positive?
|
|
100
101
|
raise ArgumentError,
|
|
101
|
-
"schedule :#{task} every: must be a
|
|
102
|
+
"schedule :#{task} every: must be a whole number of seconds (900) or answer in_seconds " \
|
|
103
|
+
"(ActiveSupport's 15.minutes); got #{given.inspect}"
|
|
102
104
|
end
|
|
103
105
|
else
|
|
104
106
|
on ||= :daily
|
|
@@ -263,7 +265,7 @@ module Asgard
|
|
|
263
265
|
end
|
|
264
266
|
|
|
265
267
|
def describe_days(days, group)
|
|
266
|
-
describe_compact(at: group.map { |entry| format("%<hour>02d:%<minute>02d", entry) }, on: day_names(days))
|
|
268
|
+
describe_compact({ at: group.map { |entry| format("%<hour>02d:%<minute>02d", entry) }, on: day_names(days) })
|
|
267
269
|
end
|
|
268
270
|
|
|
269
271
|
# The command and schedule columns for a job read back from its files.
|
|
@@ -129,7 +129,7 @@ module Asgard
|
|
|
129
129
|
klass = self.class
|
|
130
130
|
plist = klass.plist(
|
|
131
131
|
label: label(name),
|
|
132
|
-
arguments: Schedule.program_arguments(spec
|
|
132
|
+
arguments: Schedule.program_arguments([spec[:task], *spec[:args]], root: @root, asgard:, direnv:),
|
|
133
133
|
working_directory: @root,
|
|
134
134
|
environment: Schedule.environment(spec),
|
|
135
135
|
log_path: log_path(name),
|
data/lib/asgard/schedule.rb
CHANGED
|
@@ -31,7 +31,7 @@ module Asgard
|
|
|
31
31
|
def declare(task, **) = Declarations.record(declarations, place(normalize(task, **)), "schedule")
|
|
32
32
|
|
|
33
33
|
# The name a command derives (a normalize result's task and args).
|
|
34
|
-
def plain_name(spec) = command_slug(spec
|
|
34
|
+
def plain_name(spec) = command_slug([spec[:task], *spec[:args]])
|
|
35
35
|
|
|
36
36
|
# Whether +spec+ has the plain name its command derives, rather than
|
|
37
37
|
# an as: name or a hashed one.
|
|
@@ -43,7 +43,7 @@ module Asgard
|
|
|
43
43
|
derived_name?(one) && derived_name?(other) && one.values_at(:task, :args) != other.values_at(:task, :args)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def with_hashed_name(spec) = spec.merge(name: hashed_slug(spec
|
|
46
|
+
def with_hashed_name(spec) = spec.merge(name: hashed_slug([spec[:task], *spec[:args]]))
|
|
47
47
|
|
|
48
48
|
# Whether +spec+'s plain name was already given up by a rival in
|
|
49
49
|
# +declarations+, one now under its hashed name, so +spec+ takes its
|
data/lib/asgard/version.rb
CHANGED
data/lib/asgard/watch/changes.rb
CHANGED
|
@@ -15,8 +15,8 @@ module Asgard
|
|
|
15
15
|
FILE_VARIABLE = "ASGARD_CHANGES_FILE"
|
|
16
16
|
|
|
17
17
|
class << self
|
|
18
|
-
# The changes behind this process, read once from ENV.
|
|
19
|
-
#
|
|
18
|
+
# The changes behind this process, read once from ENV. Call forget
|
|
19
|
+
# to read them again; the tests do so after changing ENV.
|
|
20
20
|
def current = @current ||= from_env
|
|
21
21
|
|
|
22
22
|
def forget = @current = nil
|
|
@@ -67,7 +67,7 @@ module Asgard
|
|
|
67
67
|
|
|
68
68
|
# The watcher's log file: appends a line, rotating first (StateDir.rotate)
|
|
69
69
|
# when the file has passed limit bytes, and telling on_rotate when it did.
|
|
70
|
-
|
|
70
|
+
LogFile = Struct.new(:path, :limit, :on_rotate) do
|
|
71
71
|
def append(line)
|
|
72
72
|
on_rotate&.call if StateDir.rotate(path, max_bytes: limit)
|
|
73
73
|
File.open(path, "a") { |file| file.puts(line) }
|
|
@@ -80,7 +80,7 @@ module Asgard
|
|
|
80
80
|
# to the new log.
|
|
81
81
|
def initialize(reports, log:, state:, max_log: StateDir.log_limit, on_rotate: nil)
|
|
82
82
|
@reports = reports
|
|
83
|
-
@log =
|
|
83
|
+
@log = LogFile.new(log, max_log, on_rotate)
|
|
84
84
|
@state = state
|
|
85
85
|
@records = {}
|
|
86
86
|
@running = {} # pid => task
|
data/lib/asgard/watch/worker.rb
CHANGED
|
@@ -41,10 +41,16 @@ module Asgard
|
|
|
41
41
|
# the reports and the spawner (all shareable) and nothing else, and
|
|
42
42
|
# pops through a Mailbox so it sleeps while idle: whoever pushes onto
|
|
43
43
|
# +queue+ must wake it, through Mailbox.new(queue, the_ractor).
|
|
44
|
+
# Ruby's "Ractor API is experimental" warning is silenced here, or it
|
|
45
|
+
# would open every watcher.log; the daemon runs no user code.
|
|
44
46
|
def self.start(queue, reports, spawner: Spawner)
|
|
47
|
+
experimental = Warning[:experimental]
|
|
48
|
+
Warning[:experimental] = false
|
|
45
49
|
Ractor.new(queue, reports, spawner) do |inbox, outbox, runner|
|
|
46
50
|
Asgard::Watch::Worker.new(Asgard::Watch::Mailbox.new(inbox, Ractor.current), outbox, spawner: runner).run
|
|
47
51
|
end
|
|
52
|
+
ensure
|
|
53
|
+
Warning[:experimental] = experimental
|
|
48
54
|
end
|
|
49
55
|
|
|
50
56
|
def initialize(queue, reports, spawner: Spawner, clock: Process)
|
data/lib/asgard.rb
CHANGED
|
@@ -33,8 +33,10 @@ module Asgard
|
|
|
33
33
|
|
|
34
34
|
# `asgard schedule list`, `asgard watcher list` and `asgard jobs list`
|
|
35
35
|
# report every project's entries, so they work from a directory with no
|
|
36
|
-
# .loki above it.
|
|
37
|
-
def self.machine_wide?(argv)
|
|
36
|
+
# .loki above it, with or without leading global flags.
|
|
37
|
+
def self.machine_wide?(argv)
|
|
38
|
+
[%w[schedule list], %w[watcher list], %w[jobs list], %w[jobs]].include?(argv.drop_while { global_flag?(it) }.first(2))
|
|
39
|
+
end
|
|
38
40
|
|
|
39
41
|
# The root .loki is loaded directly rather than through `import`, so
|
|
40
42
|
# record it the way import would. Otherwise an `import_up` in a child
|
|
@@ -108,10 +110,28 @@ module Asgard
|
|
|
108
110
|
end
|
|
109
111
|
|
|
110
112
|
# Whether +word+ is what Thor would take as a task name: a task, a mapped
|
|
111
|
-
# name, or an abbreviation of either.
|
|
112
|
-
#
|
|
113
|
+
# name, or an abbreviation of either. A task's full name counts with
|
|
114
|
+
# dashes for underscores (deploy-app) and when the task is hidden, as
|
|
115
|
+
# Thor runs both; Thor expands no abbreviation to a hidden task. Options,
|
|
116
|
+
# the gem's reserved `_` names and the empty word (a prefix of every
|
|
117
|
+
# task) are not.
|
|
113
118
|
def self.task_word?(word, tasks = Tasks)
|
|
114
|
-
|
|
119
|
+
return false if word.empty? || word.start_with?("-", "_")
|
|
120
|
+
|
|
121
|
+
tasks.all_commands.key?(word.tr("-", "_")) || tasks.send(:find_command_possibilities, word).any?
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
HELP_FLAGS = %w[--help -h].freeze
|
|
125
|
+
|
|
126
|
+
# `asgard TASK --help` (or -h) as `asgard help TASK`, so the task shows
|
|
127
|
+
# its help instead of running with --help as its argument. Only when
|
|
128
|
+
# nothing but global flags comes with the help flag.
|
|
129
|
+
def self.help_first(argv, tasks = Tasks)
|
|
130
|
+
word, *rest = argv
|
|
131
|
+
return argv unless word && rest.intersect?(HELP_FLAGS) && rest.all? { HELP_FLAGS.include?(it) || global_flag?(it) }
|
|
132
|
+
return argv unless task_word?(word, tasks)
|
|
133
|
+
|
|
134
|
+
["help", word, *(rest - HELP_FLAGS)]
|
|
115
135
|
end
|
|
116
136
|
|
|
117
137
|
# Main entry point invoked by the asgard executable.
|
|
@@ -120,7 +140,9 @@ module Asgard
|
|
|
120
140
|
boot(argv)
|
|
121
141
|
Tasks._reset_ran!
|
|
122
142
|
pin_project_root(project_root)
|
|
123
|
-
|
|
143
|
+
argv = help_first(task_first(argv) { |word| task_word?(word) })
|
|
144
|
+
Tasks.check_default_task!(argv)
|
|
145
|
+
result = Tasks.start(argv)
|
|
124
146
|
# Quality-gate convention: a task signals failure by returning :fail
|
|
125
147
|
# (see dev/quality.loki's *_check tasks). Surface that as a nonzero
|
|
126
148
|
# exit so callers (CI, cross-repo runners) can rely on $?.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: asgard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dewayne VanHoozer
|
|
@@ -106,10 +106,10 @@ dependencies:
|
|
|
106
106
|
- !ruby/object:Gem::Version
|
|
107
107
|
version: "0.2"
|
|
108
108
|
description: |
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
A powerful Ruby-based task runner for any kind of project with task dependency tracking
|
|
110
|
+
and concurrent execution of designated tasks. Uses Thor for its rich CLI options, with
|
|
111
|
+
dotenv, sh/shebang helpers, importable task files, scheduled execution of tasks via
|
|
112
|
+
launchd (macOS) or systemd timers (Linux), a file watcher and background jobs.
|
|
113
113
|
email:
|
|
114
114
|
- dewayne@vanhoozer.me
|
|
115
115
|
executables:
|
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
191
191
|
- !ruby/object:Gem::Version
|
|
192
192
|
version: "0"
|
|
193
193
|
requirements: []
|
|
194
|
-
rubygems_version: 4.1.0
|
|
194
|
+
rubygems_version: 4.1.0
|
|
195
195
|
specification_version: 4
|
|
196
196
|
summary: A powerful Ruby-based task runner
|
|
197
197
|
test_files: []
|