Class: Trove::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/trove/cli.rb

Instance Method Summary collapse

Instance Method Details

#delete(filename = nil) ⇒ Object



42
43
44
# File 'lib/trove/cli.rb', line 42

def delete(filename = nil)
  Trove.delete(filename)
end

#initObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trove/cli.rb', line 8

def init
  create_file "trove/.keep", ""

  if File.exist?(".gitignore")
    contents = <<~EOS

      # Ignore Trove storage
      /trove/*
      !/trove/.keep
    EOS
    unless File.read(".gitignore").include?(contents)
      append_to_file(".gitignore", contents)
    end
  else
    say "Check in trove/.keep and ignore trove/*"
  end

  create_file ".trove.yml", <<~EOS
    storage: s3://my-bucket/trove
  EOS
end

#listObject



47
48
49
50
51
52
# File 'lib/trove/cli.rb', line 47

def list
  say table(
    Trove.list,
    [:filename, :size, :updated_at]
  )
end

#pull(filename = nil) ⇒ Object



37
38
39
# File 'lib/trove/cli.rb', line 37

def pull(filename = nil)
  Trove.pull(filename, version: options[:version])
end

#push(filename) ⇒ Object



31
32
33
# File 'lib/trove/cli.rb', line 31

def push(filename)
  Trove.push(filename)
end

#versionObject



55
56
57
# File 'lib/trove/cli.rb', line 55

def version
  say Trove::VERSION
end

#versions(filename) ⇒ Object



60
61
62
63
64
65
# File 'lib/trove/cli.rb', line 60

def versions(filename)
  say table(
    Trove.versions(filename),
    [:version, :size, :updated_at]
  )
end