Class: Bucket::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/bucket/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CLI

Returns a new instance of CLI.



8
9
10
11
12
# File 'lib/bucket/cli.rb', line 8

def initialize(*args)
  super

  @client = Bucket::Client.new load_config
end

Instance Method Details

#clone(user, name) ⇒ Object



29
30
31
# File 'lib/bucket/cli.rb', line 29

def clone(user, name)
  `git clone #{@client.repo_url(user, name)}`
end

#init(directory) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/bucket/cli.rb', line 37

def init(directory)
  expanded_dir = File.expand_path(directory)
  `git init #{expanded_dir}`
  
  repo = @client.create_repo(options[:name] || File.basename(expanded_dir), options)
  `git remote add origin #{@client.repo_url(repo[:owner], repo[:slug])}`

  say("Repository #{@client.repo_full_name(repo)} created.")
end

#reposObject



22
23
24
25
26
# File 'lib/bucket/cli.rb', line 22

def repos
  @client.repos_list.each do |repo|
    say(@client.repo_full_name(repo))
  end
end

#setupObject



15
16
17
18
19
# File 'lib/bucket/cli.rb', line 15

def setup
  generate_config

  say("Configuration saved to ~/.bucket")
end