Class: TryRb::CLI
- Inherits:
-
Thor
- Object
- Thor
- TryRb::CLI
- Defined in:
- lib/tryrb/cli.rb
Instance Method Summary collapse
Instance Method Details
#config ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tryrb/cli.rb', line 31 def config default_tmp_path = "~/tmp/tryrb" tmp_dir = ask("Please specify your dir of the tmp files(default: #{default_tmp_path}):") tmp_dir = default_tmp_path if tmp_dir.empty? default_editor = "vim" editor = ask("Please specify your favorite editor(default: #{default_editor}):") editor = default_editor if editor.empty? config = {'tmp_dir' => tmp_dir, 'editor' => editor} rc_path = conf. File.open(rc_path, 'w') do |f| f.write(config.to_yaml) end say("The config have been writen to ~/.tryrbrc", :green) end |
#create(key_name = "") ⇒ Object
15 16 17 18 |
# File 'lib/tryrb/cli.rb', line 15 def create(key_name="") @key_name = key_name system([conf.editor, fullpath] * ' ') end |
#exec(filename = nil) ⇒ Object
23 24 25 26 27 |
# File 'lib/tryrb/cli.rb', line 23 def exec(filename=nil) file_path = find_file(:filename => filename, :last_n => [:last]) abort "Can't find the file you want" unless file_path system(['ruby', file_path] * ' ') end |