Class: Lyman::CLI::Root
- Inherits:
-
Thor
- Object
- Thor
- Lyman::CLI::Root
- Defined in:
- lib/lyman/cli.rb
Overview
The legible table of contents for every lyman command. Root wires Thor's argument parsing to a plain object per command (lib/lyman/cli/commands/*.rb) and nothing else — no command grows its body here.
Command contract: every command class is built as
Commands::X.new(thor, source_root:).call(*args).
thoris this Root instance, passed through so a command can use Thor's UI helpers (thor.yes?,thor.say) without inheriting from Thor itself — commands are plain objects, not Thor subclasses.source_root:is where artifacts are read from (the gem tree by default; overridable via LYMAN_SOURCE_ROOT so tests can point it at a fixture that simulates a newer lyman release).#call's positional args are whatever the command needs (an artifact/project name, or nothing). Project-root discovery (Manifest.find!) happens inside each command that needs it —newis the one command that doesn't have a project root yet.
Class Method Summary collapse
Instance Method Summary collapse
- #add(artifact) ⇒ Object
- #diff(artifact) ⇒ Object
- #doctor ⇒ Object
- #eject(artifact) ⇒ Object
- #list ⇒ Object
- #new(name) ⇒ Object
- #update ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
34 35 36 |
# File 'lib/lyman/cli.rb', line 34 def self.exit_on_failure? true end |
Instance Method Details
#add(artifact) ⇒ Object
47 48 49 |
# File 'lib/lyman/cli.rb', line 47 def add(artifact) Commands::Add.new(self, source_root: source_root).call(artifact, force: [:force]) end |
#diff(artifact) ⇒ Object
62 63 64 |
# File 'lib/lyman/cli.rb', line 62 def diff(artifact) Commands::Diff.new(self, source_root: source_root).call(artifact) end |
#doctor ⇒ Object
67 68 69 |
# File 'lib/lyman/cli.rb', line 67 def doctor Commands::Doctor.new(self, source_root: source_root).call end |
#eject(artifact) ⇒ Object
57 58 59 |
# File 'lib/lyman/cli.rb', line 57 def eject(artifact) Commands::Eject.new(self, source_root: source_root).call(artifact) end |
#list ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/lyman/cli.rb', line 72 def list manifest_root = Manifest.find manifest = Manifest.load(manifest_root) if manifest_root Registry::ARTIFACTS.each do |name, spec| status = if manifest entry = manifest.artifact(name) entry ? entry["status"] : "not planted" end role = "#{spec[:role]}#{", opt-in" if spec[:optional]}" line = "#{name} (#{role}) #{spec[:dest]}#{" — #{status}" if status} — #{spec[:description]}" say line end end |
#new(name) ⇒ Object
39 40 41 |
# File 'lib/lyman/cli.rb', line 39 def new(name) Commands::New.new(self, source_root: source_root).call(name) end |
#update ⇒ Object
52 53 54 |
# File 'lib/lyman/cli.rb', line 52 def update Commands::Update.new(self, source_root: source_root).call end |
#version ⇒ Object
90 91 92 |
# File 'lib/lyman/cli.rb', line 90 def version say VERSION end |