lib/gemfile_locker/cli.rb in gemfile_locker-0.1.0 vs lib/gemfile_locker/cli.rb in gemfile_locker-0.2.0
- old
+ new
@@ -1,43 +1,42 @@
require 'thor'
module GemfileLocker
class CLI < Thor
- desc 'lock [Gemfile]', 'Lock dependencies.'
+ class_option :gemfile,
+ aliases: '-g',
+ default: 'Gemfile',
+ desc: 'Path to gemfile'
+
+ desc 'lock [gem ...] [options]', 'Lock all missing versions or specified gems.'
method_option :loose,
aliases: '-l',
lazy_default: 'patch',
enum: %w(major minor patch full),
desc: 'Lock with `~>`. Optionaly provide level (default to patch)'
- method_option :only,
- aliases: '-o',
- type: :array,
- desc: 'List of gems to process'
method_option :except,
aliases: '-e',
type: :array,
desc: 'List of gems to skip'
method_option :force,
aliases: '-f',
type: :boolean,
- desc: 'Overwrite version definitions ' \
- '(By default it adds only missing version definitions)'
- def lock(file = 'Gemfile')
- lockfile = File.read("#{file}.lock")
- run_editor file, Locker.new(lockfile, options)
+ desc: 'Overwrite version definitions'
+ def lock(*only)
+ gemfile = options[:gemfile]
+ lockfile = File.read("#{gemfile}.lock")
+ processor_opts = only.any? ? options.merge(only: only) : options
+ run_editor gemfile, Locker.new(lockfile, processor_opts)
end
- desc 'unlock [Gemfile]', 'Unlock dependencies.'
- method_option :only,
- aliases: '-o',
- type: :array,
- desc: 'List of gems to process'
+ desc 'unlock [gem ...] [options]', 'Unock all or specified gems.'
method_option :except,
aliases: '-e',
type: :array,
desc: 'List of gems to skip'
- def unlock(file = 'Gemfile')
- run_editor file, Unlocker.new(options)
+ def unlock(*only)
+ processor_opts = only.any? ? options.merge(only: only) : options
+ run_editor options[:gemfile], Unlocker.new(processor_opts)
end
private
def run_editor(file, processor)