Class: Renuo::CLI

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

Instance Method Summary collapse

Instance Method Details

#start ⇒ Object



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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/renuo/cli.rb', line 19

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

  info = Gems.info Renuo::Cli::NAME

  if Gem::Version.new(Renuo::Cli::VERSION) < Gem::Version.new(info['version'])
    say "You are running the version #{Renuo::Cli::VERSION} but the brand new #{info['version']} is available. 🎉"
    if agree("Why don't you update with `gem update renuo-cli`? I can run it for you. 💪")
      system("gem update #{Renuo::Cli::NAME}")
      abort 'Nice! I updated myself. 🤩 Now you can run the command again.'
    end
    abort('Good. Just do it yourself then...😒')
    exit
  end

  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 '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 'upgrade-laptop' do |c|
    c.syntax = 'renuo upgrade-laptop'
    c.summary = 'Upgrades the installed apps from the app store, macOS and homebrew'
    c.description = 'Upgrades the installed apps from the app store, macOS and homebrew'
    c.example 'renuo upgrade-laptop', 'upgrades your laptop'
    c.action do
      UpgradeLaptop.new.run
    end
  end

  command 'create-new-logins' do |c|
    c.syntax = 'renuo create-new-logins'
    c.summary = 'Guides you through the sign up pages for Sentry, NewRelic and Gemnasium'
    c.description = 'Guides you through the sign up pages for Sentry, NewRelic and Gemnasium'
    c.example 'renuo create-new-logins', 'creates new logins'
    c.action do
      CreateNewLogins.new.run
    end
  end

  command 'create-aws-project' do |c|
    c.syntax = 'renuo create-aws-project'
    c.summary = 'Generates necessary commands for our project setup on AWS incl. necessary installations.'
    c.description = "      This creates commands for creating AWS users, buckets an versioning policies and CloudFront. \n      It also guides you to set up the necessary environment.\n\n      You will be asked for:\n      (- installation of aws-cli, if not yet done)\n      (- setting up aws user `renuo-app-setup`, if not yet done)\n      - project name and suffix so that the script can respect our naming conventions\n      - the Redmine project name to tag buckets for AWS billing references\n      - whether you want to setup CloudFront to deliver assets via S3\n\n      The generated commands do the following:\n      - create an IAM user for each environment (master, develop, testing) and add it to the renuo apps group.\n      - create S3 buckets for each user who owns it\n      - tag the buckets\n      - enable versioning for master buckets\n      (- set up a CloudFront distribution for each environment with the default config or plus alias if configured)\n    DESCRIPTION\n    c.example 'Setup a project (you will be asked for details)', 'renuo create-aws-project'\n    c.action do |_args, _options|\n      CreateAwsProject.new.run\n    end\n  end\n\n  command 'release' do |c|\n    c.syntax = 'renuo release'\n    c.summary = 'Release a projects state of develop (on github) to master in one command.'\n    c.description = 'Creates a new release version of a project on master as either a Major, Minor, '\\\n                    'Patch or Custom release based on the current state of develop on Github'\n    c.example 'renuo release my-project minor', 'release a minor release of my-project'\n    c.example 'renuo release my-project custom 2.5.0', 'release my-project as release 2.5.0'\n    c.action do|args|\n      ReleaseProject.new.run(args)\n    end\n  end\n\n  command 'create-heroku-app' do |c|\n    c.syntax = 'renuo create-heroku-app'\n    c.summary = 'Generates the script necessary to setup an application on Heroku.'\n    c.description = 'Generates the script necessary to setup an application on Heroku.'\n    c.example 'renuo create-heroku-app hello', 'generates the command to create hello on Heroku'\n    c.action do|args|\n      CreateHerokuApp.new.run(args)\n    end\n  end\n\n  command 'fetch-emails' do |c|\n    c.syntax = 'renuo fetch-emails'\n    c.summary = 'Retrieves all renuo employees email addresses'\n    c.description = 'Retrieves all renuo employees email addresses. One per line.'\n    c.action do|args|\n      FetchEmails.new.run(args)\n    end\n  end\n\n  command 'heroku-users' do |c|\n    c.syntax = 'renuo heroku-users add/remove emailaddress'\n    c.summary = 'Prints a list of commands to add or remove an email address from all Heroku projects'\n    c.description = 'Useful when a new person is hired or a person quits.'\n    c.example 'renuo heroku-users add [email protected]',\n              'Adds the user [email protected] to all the Heroku projects'\n    c.example 'renuo heroku-users remove [email protected]',\n              'Removes the user [email protected] from all the Heroku projects'\n    c.action do|args|\n      HerokuUsers.new.run(args)\n    end\n  end\nend\n"