Sha256: 9c6c77d7d0a865beb7caa34d6b473fc5b358eb74fe19fc703eea25587ec862aa
Contents?: true
Size: 778 Bytes
Versions: 5
Compression:
Stored size: 778 Bytes
Contents
module LearnOpen class ArgumentParser attr_reader :args def initialize(args) @args = args end def execute config_path = File.expand_path('~/.learn-config') editor_data = YAML.load(File.read(config_path))[:editor] lesson = nil configured_editor = !(editor_data.empty? || editor_data.nil?) ? editor_data : nil editor_specified = ARGV.detect {|arg| arg.start_with?('--editor=')}.match(/\-\-editor=(.+)/) || configured_editor open_after = !!editor_specified if !ARGV[0].start_with?('--editor=') lesson = ARGV[0] end if open_after editor_specified = editor_specified.is_a?(String) ? editor_specified : editor_specified[1] end [lesson, editor_specified] end end end
Version data entries
5 entries across 5 versions & 1 rubygems