Class: RubySkills::CLI
- Inherits:
-
Thor
- Object
- Thor
- RubySkills::CLI
- Defined in:
- lib/ruby_skills/cli.rb
Overview
Thor-based command-line interface for Ruby Skills.
The default command is #help. -h and --help are aliases for it.
Instance Method Summary collapse
-
#help(command = nil, subcommand = false) ⇒ void
List every available command, or describe a single command.
-
#init ⇒ void
Create a Skillfile and
.ruby-skillsdirectory in the current project. -
#install(skill = nil) ⇒ void
Install one skill or every skill declared in the Skillfile.
-
#list ⇒ void
Print installed skills from the lockfile.
-
#remove(skill) ⇒ void
Remove an installed skill from the project.
-
#update(skill = nil) ⇒ void
Update one skill or every installed skill.
-
#version ⇒ void
Print the installed gem version.
Instance Method Details
#help(command = nil, subcommand = false) ⇒ void
This method returns an undefined value.
List every available command, or describe a single command.
31 32 33 |
# File 'lib/ruby_skills/cli.rb', line 31 def help(command = nil, subcommand = false) super end |
#init ⇒ void
This method returns an undefined value.
Create a Skillfile and .ruby-skills directory in the current project.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby_skills/cli.rb', line 40 def init config = Config.new config.initialize_project! say "Ruby Skills initialized" say " Skillfile created" say " .ruby-skills directory created" rescue RubySkills::Error => e say "Error: #{e.}", :red exit 1 end |
#install(skill = nil) ⇒ void
This method returns an undefined value.
Install one skill or every skill declared in the Skillfile.
59 60 61 62 63 64 |
# File 'lib/ruby_skills/cli.rb', line 59 def install(skill = nil) Installer.new.install(skill) rescue RubySkills::Error => e say "Error: #{e.}", :red exit 1 end |
#list ⇒ void
This method returns an undefined value.
Print installed skills from the lockfile.
With --json, emit a machine-readable payload instead of a table.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ruby_skills/cli.rb', line 74 def list skills = Lockfile.new.skills if [:json] puts JSON.generate(list_payload(skills)) return end if skills.empty? say "No skills installed." return end say "Installed skills:" say "" skills.each do |name, data| say "#{name.ljust(35)} #{data["version"]}" end end |
#remove(skill) ⇒ void
This method returns an undefined value.
Remove an installed skill from the project.
101 102 103 104 105 106 |
# File 'lib/ruby_skills/cli.rb', line 101 def remove(skill) Remover.new.remove(skill) rescue RubySkills::Error => e say "Error: #{e.}", :red exit 1 end |
#update(skill = nil) ⇒ void
This method returns an undefined value.
Update one skill or every installed skill.
114 115 116 117 118 119 |
# File 'lib/ruby_skills/cli.rb', line 114 def update(skill = nil) Updater.new.update(skill) rescue RubySkills::Error => e say "Error: #{e.}", :red exit 1 end |
#version ⇒ void
This method returns an undefined value.
Print the installed gem version.
125 126 127 |
# File 'lib/ruby_skills/cli.rb', line 125 def version say "ruby-skills #{RubySkills::VERSION}" end |