lib/termup/cli.rb in termup-2.0.3 vs lib/termup/cli.rb in termup-3.0.0

- old
+ new

@@ -1,10 +1,8 @@ require 'thor' module Termup - TERMUP_DIR = File.join(ENV['HOME'],'.config','termup') - class Cli < Thor include Thor::Actions class << self def source_root @@ -24,12 +22,12 @@ edit(project) end desc 'edit PROJECT', 'Edit termup project (Shortcut: e)' def edit(project) - unless File.exists?(path(project)) - empty_directory TERMUP_DIR + unless path(project).exist? + empty_directory Termup::Dir if options['iterm_advanced'] template 'templates/iterm_advanced.yml', path(project) elsif options['iterm_basic'] template 'templates/iterm_basic.yml', path(project) else @@ -40,22 +38,27 @@ system("#{editor} #{path(project)}") end desc 'list', 'List termup projects (Shortcut: l)' def list - projects = Dir["#{TERMUP_DIR}/*.yml"].map{|file| File.basename(file,'.yml') } + projects = Pathname.glob(Termup::Dir.join('*.yml')).map{|f| f.basename('.yml') } say "Your projects: #{projects.join(', ')}" end desc 'start PROJECT', 'Start termup project (Shortcut: s)' def start(project) - say "project \"#{project}\" doesn't exist!" and return unless File.exists?(path(project)) - Termup::Base.new(project) + say "project \"#{project}\" doesn't exist!" and return unless path(project).exist? + process = Termup::Process.new + if process.iterm? + Termup::Iterm.new(project, process).start + else + Termup::Terminal.new(project, process).start + end end protected def path(project) - "#{TERMUP_DIR}/#{project}.yml" + Termup::Dir.join("#{project}.yml") end end end