Class: Renuo::CLI

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

Instance Method Summary collapse

Instance Method Details

#start ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/renuo/cli.rb', line 12

def start
  require 'commander/import'
  program :version, Renuo::Cli::VERSION
  program :description, 'renuo CLI'

  command 'display-name'.to_sym do |c|
    c.syntax = 'renuo display-name [options]'
    c.summary = 'Sets the name of a customer on the Renuo dashboard'
    c.description = 'Sets the name of a customer on the Renuo dashboard'
    c.example 'Display "Peter Muster" on the dashboard', 'renuo display-name "Peter Muster"'
    c.example 'Remove the current name from the dashboard', 'renuo display-name --delete'
    c.option '--delete', 'Deletes the current name'
    c.action do |args, options|
      NameDisplay.new.run(args, options)
    end
  end

  command :config do |c|
    c.syntax = 'renuo config [options]'
    c.summary = 'Setup the config (API keys)'
    c.description = 'Setup the config (API keys)'
    c.action do
      key = ask('API Key?') { |q| q.echo = '*' }
      LocalStorage.new.store(:api_key, key)
      say('stored the api key')
    end
  end

  command 'migrate-to-github' do |c|
    c.syntax = 'renuo migrate-to-github [project]'
    c.summary = 'A guide how to migrate from gitlab to github'
    c.description = 'A guide how to migrate from gitlab to github'
    c.example 'migrate the renuo-cli project', 'renuo migrate-to-github renuo-cli'
    c.action do |args, _options|
      MigrateToGithub.new(args.first).run
    end
  end

  command 'list-large-git-files' do |c|
    c.syntax = 'renuo list-large-git-files'
    c.summary = 'Lists the 5 largest files in a git repository. Warning: must be a bare checkout of the repo!'
    c.description = "Lists the 5 largest files in a git repository.\nWarning: must be a bare checkout of the repo!"
    c.example 'list the 5 largest git files of github.com/renuo/renuo-cli',
              'git clone --bare [email protected]:renuo/renuo-cli.git && '\
              'cd renuo-cli.git && renuo list-large-git-files'
    c.action do
      ListLargeGitFiles.new.run
    end
  end

  command 'generate-password' do |c|
    c.syntax = 'renuo generate-password'
    c.summary = 'Generates a phrase of random 0-9a-zA-Z characters. Choose a substring of it as a new password.'
    c.description = 'Generates a phrase of random 0-9a-zA-Z characters. Choose a substring of it as a new password.'
    c.example 'renuo generate-password', 'generates a random password'
    c.action do
      GeneratePassword.new.run
    end
  end

  command 'application-setup-auto-config' do |c|
    c.syntax = 'renuo application-setup-auto-config'
    c.summary = 'Sets up the application setup using the default config'
    c.description = 'Generates a phrase of random 0-9a-zA-Z characters. Choose a substring of it as a new password.'
    c.example 'renuo application-setup-auto-config', 'applies the default config'
    c.action do
      ApplicationSetupAutoConfig.new.run
    end
  end
end