Class: Martilla::CLI
- Inherits:
-
Thor
- Object
- Thor
- Martilla::CLI
- Defined in:
- lib/martilla/cli.rb
Instance Method Summary collapse
Instance Method Details
#backup(filepath) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/martilla/cli.rb', line 8 def backup(filepath) file_path = Pathname.new(filepath) file_path = File.join(Dir.pwd, file_path) if file_path.relative? begin backup_config = YAML.load_file(file_path) rescue Psych::SyntaxError puts "Invalid yaml-file found, at #{file_path}" rescue Errno::EACCES puts "Couldn't access file due to permissions at #{file_path}" rescue Errno::ENOENT puts "Couldn't access non-existent file #{file_path}" else backup = Backup.create(backup_config) end end |
#setup(filename = 'martilla.yml') ⇒ Object
25 26 27 28 |
# File 'lib/martilla/cli.rb', line 25 def setup(filename = 'martilla.yml') file_path = File.join(Dir.pwd, filename) File.write(file_path, Backup.sample_config.to_yaml) end |
#version ⇒ Object
31 32 33 |
# File 'lib/martilla/cli.rb', line 31 def version puts VERSION end |