dawn-cli 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c69df2b06d2b520437bb91ae452de45c88693ce
4
- data.tar.gz: cbc1a3bd916fc0aab3651867f8b2ddf797142c11
3
+ metadata.gz: 5648f22bab9ddaf3fc4b15aa7d442e8cd14dde2d
4
+ data.tar.gz: 755487a68afc3f624344ad1fcb171147cbe9b3eb
5
5
  SHA512:
6
- metadata.gz: 11d3f2f1ddd10804df98ab8f571a3f36de4369bc101bccc3c8619b6931eb65f21abe7e5563c79d5c48f8af195f2b0ebd0ea984c6388729ff46578c34d3b058f8
7
- data.tar.gz: b1c12805372cca918d79124a7de6f66f44dc1a66c516143ce8d5a12fa125105e6cc4e61d9b0bd182879292854c48e2c345da8bbe23474e7f08bf71e06f3ec79c
6
+ metadata.gz: 32142f2d3d226bf03a43fc4b6fe6c3f73173d5a56a8a4c4df47eb20225c9d16ffd81e0d5d9909bb55a359e6313464c3a44cc22d7ac9e0047ea103e1571f0554f
7
+ data.tar.gz: ee71bb731ff703315c787c644680359c53a6958aed662a3325990947346daf39746902c5100cced416d8ad332bb3508efca9c5ec79aa5c39de9a54e7d5218eed
@@ -6,6 +6,16 @@ module Dawn
6
6
 
7
7
  extend Dawn::CLI::Helpers
8
8
 
9
+ # "Create a new dawn App (with git; setup)"
10
+ def self.create(appname=nil)
11
+ app = try_create_app appname
12
+ # since its possible for dawn to create a new app, with a random name
13
+ # setting the appname again based on the real app's name is required
14
+ appname = app.name
15
+ git_add_dawn_remote app
16
+ say "\tAPP\t#{app.name}"
17
+ end
18
+
9
19
  # "Displays a list of all the apps you have deployed to dawn"
10
20
  def self.list
11
21
  say format_apps(Dawn::App.all)
@@ -10,16 +10,6 @@ module Dawn
10
10
  Dawn::API.health_check
11
11
  end
12
12
 
13
- # "Create a new dawn App (with git; setup)"
14
- def self.create(appname=nil)
15
- app = try_create_app appname
16
- # since its possible for dawn to create a new app, with a random name
17
- # setting the appname again based on the real app's name is required
18
- appname = app.name
19
- git_add_dawn_remote app
20
- say "\tAPP\t#{app.name}"
21
- end
22
-
23
13
  end
24
14
  end
25
15
  end
@@ -1,93 +1,131 @@
1
1
  require "docopt"
2
2
  require 'highline/import'
3
+ require "dawn/cli/commands"
4
+ require "dawn/cli/version"
3
5
 
4
6
  module Dawn
5
7
  module CLI
6
- DOC_TOP = %Q(Usage:
7
- dawn --version
8
- dawn [-a APPNAME] [-h] <command> [<argv>...]
8
+ DOC_TOP =
9
+ %Q(usage: dawn [-a APPNAME] [-h] [<command>] [<argv>...]
10
+
11
+ Options:
12
+ -a APPNAME, --app=APPNAME specify app.
13
+ -h, --help display help.
14
+ --version print version.
9
15
 
10
16
  Commands:
11
- create [<name>]
12
- ls
13
- ps
14
- login
17
+ create [<name>] initialize a new app in this the wd.
18
+ ls print all deployed apps.
19
+ ps print all running gears for current app.
20
+ login setup your netrc login details for dawn.
15
21
  logs [-f]
16
- -f, --follow follow logs
17
- app
18
- domain
19
- drain
20
- env
21
- key
22
- release
23
- run
24
-
25
- Options:
26
- -a APPNAME, --app=APPNAME specify app
27
- -h, --help display help
28
- --version print version
22
+ -f, --follow follow logs.
23
+ app App control command.
24
+ domain Domain control command.
25
+ drain Drain control command.
26
+ env ENV control command.
27
+ key Key control command.
28
+ release Release control command.
29
+ run run command on current app.
29
30
  )
30
31
 
31
32
  DOC_SUBCOMMAND = {}
32
- DOC_SUBCOMMAND["app"] = %Q(Usage:
33
- dawn app list all avaiable apps
34
- dawn app <command>
33
+ DOC_SUBCOMMAND["app"] =
34
+ %Q(usage: dawn app
35
+ dawn app delete
36
+ dawn app restart
37
+ dawn app scale <gear_modifier>...
38
+
39
+ Options:
40
+ -h, --help display help.
35
41
 
36
42
  Commands:
37
- delete
38
- restart
39
- scale <gear_modifier>
40
-
41
- GearModifier:
42
- type=number
43
- type+number
44
- type-number
43
+ delete remove the app from dawn.
44
+ restart self explanatory.
45
+ scale scale app services.
46
+ gear_modifier takes the format
47
+ type=number, type+number or type-number
48
+ EG: web=3 db+1
49
+
50
+ if no command is given, prints all available apps.
45
51
  )
46
52
 
47
- DOC_SUBCOMMAND["domain"] = %Q(Usage:
48
- dawn domain list all domains for current app
49
- dawn domain [<command>]
53
+ DOC_SUBCOMMAND["domain"] =
54
+ %Q(usage: dawn domain
55
+ dawn domain add <url>
56
+ dawn domain delete <url>
57
+
58
+ Options:
59
+ -h, --help display help.
50
60
 
51
61
  Commands:
52
- add <url>
53
- delete <url>
62
+ add add a new domain to the current app.
63
+ delete remove a domain from the current app.
64
+
65
+ if no command is given, prints all domains for current app.
66
+
54
67
  )
55
68
 
56
- DOC_SUBCOMMAND["drain"] = %Q(Usage:
57
- dawn drain list all drains for current app
58
- dawn drain [<command>]
69
+ DOC_SUBCOMMAND["drain"] =
70
+ %Q(usage: dawn drain
71
+ dawn drain add <url>
72
+ dawn drain delete <url>
73
+
74
+ Options:
75
+ -h, --help display help.
59
76
 
60
77
  Commands:
61
- add <url>
62
- delete <url>
78
+ add add a new log drain to current app.
79
+ delete remove a log drain from the current app.
80
+
81
+ if no command is given, prints all drains for current app.
63
82
  )
64
83
 
65
- DOC_SUBCOMMAND["env"] = %Q(Usage:
66
- dawn env print the ENV for the current app
67
- dawn env [<command>]
84
+ DOC_SUBCOMMAND["env"] =
85
+ %Q(usage: dawn env
86
+ dawn env get <key_name>...
87
+ dawn env set <key_name=value>...
88
+ dawn env unset <key_name>...
89
+
90
+ Options:
91
+ -h, --help display help.
68
92
 
69
93
  Commands:
70
- get <key_name>...
71
- set <key_name=value>...
72
- unset <key_name>...
94
+ get print filtered ENV variables.
95
+ set set ENV variables.
96
+ unset unset ENV variables.
97
+
98
+ if no command is given, prints the ENV for the current app.
73
99
  )
74
100
 
75
- DOC_SUBCOMMAND["key"] = %Q(Usage:
76
- dawn key list all keys deployed to dawn
77
- dawn key [<command>]
101
+ DOC_SUBCOMMAND["key"] =
102
+ %Q(usage: dawn key
103
+ dawn key add
104
+ dawn key delete <id>
105
+ dawn key get <id>
106
+
107
+ Options:
108
+ -h, --help display help.
78
109
 
79
110
  Commands:
80
- add
81
- delete <id>
82
- get <id>
111
+ add add your current public key to dawn.
112
+ delete remove a key.
113
+ get retrieve a key.
114
+
115
+ if no command is given, prints all keys deployed to dawn.
83
116
  )
84
117
 
85
- DOC_SUBCOMMAND["release"] = %Q(Usage:
86
- dawn release list all releases for the current app
87
- dawn release [<command>]
118
+ DOC_SUBCOMMAND["release"] =
119
+ %Q(usage: dawn release
120
+ dawn release add
121
+
122
+ Options:
123
+ -h, --help display help.
88
124
 
89
125
  Commands:
90
- add
126
+ add create a new release for the current app.
127
+
128
+ if no command is given, list all releases for the current app.
91
129
  )
92
130
 
93
131
  @@selected_app = nil
@@ -118,64 +156,52 @@ Commands:
118
156
  # @param [String] command
119
157
  # @param [Hash] options
120
158
  ###
121
- def self.run_app_command(command, options)
122
- case command.to_s
123
- when ""
124
- Dawn::CLI::App.list
125
- when "delete"
159
+ def self.run_app_command(options)
160
+ if options["delete"]
126
161
  Dawn::CLI::App.delete
127
- when "restart"
162
+ elsif options["restart"]
128
163
  Dawn::CLI::App.restart
129
- when "scale"
130
- data = options["<argv>"].inject({}) do |str, hash|
164
+ elsif options["scale"]
165
+ data = options["<gear_modifier>"].inject({}) do |str, hash|
131
166
  if str =~ /(\S+)([+-=])(\d+)/
132
167
  hash[$1] = [$2, $3.to_i]
133
168
  end
134
169
  end
135
170
  Dawn::CLI::App.scale(data)
136
171
  else
137
- not_a_command("dawn app", command)
172
+ Dawn::CLI::App.list
138
173
  end
139
174
  end
140
175
 
141
- def self.run_domain_command(command, options)
142
- case command.to_s
143
- when ""
144
- Dawn::CLI::Domain.list
145
- when "add"
146
- url = options["<argv>"].first
176
+ def self.run_domain_command(options)
177
+ if options["add"]
178
+ url = options["<url>"]
147
179
  Dawn::CLI::Domain.add(url)
148
- when "delete"
149
- url = options["<argv>"].first
180
+ elsif options["delete"]
181
+ url = options["<url>"]
150
182
  Dawn::CLI::Domain.delete(url)
151
183
  else
152
- not_a_command("dawn domain", command)
184
+ Dawn::CLI::Domain.list
153
185
  end
154
186
  end
155
187
 
156
- def self.run_drain_command(command, options)
157
- case command.to_s
158
- when ""
159
- Dawn::CLI::Drain.list
160
- when "add"
161
- url = options["<argv>"].first
188
+ def self.run_drain_command(options)
189
+ if options["add"]
190
+ url = options["<url>"]
162
191
  Dawn::CLI::Drain.add(url)
163
- when "delete"
164
- url = options["<argv>"].first
192
+ elsif options["delete"]
193
+ url = options["<url>"]
165
194
  Dawn::CLI::Drain.delete(url)
166
195
  else
167
- not_a_command("dawn drain", command)
196
+ Dawn::CLI::Drain.list
168
197
  end
169
198
  end
170
199
 
171
- def self.run_env_command(command, options)
172
- case command.to_s
173
- when ""
174
- Dawn::CLI::Env.list
175
- when "get"
176
- keys = options["<argv>"]
200
+ def self.run_env_command(options)
201
+ if options["get"]
202
+ keys = options["<key_name>"]
177
203
  Dawn::CLI::Env.get(*keys)
178
- when "set"
204
+ elsif options["set"]
179
205
  data = options["<argv>"].each_with_object({}) do |str, hash|
180
206
  if str =~ /(\S+)=(.*)/
181
207
  key, value = $1, $2
@@ -183,80 +209,84 @@ Commands:
183
209
  end
184
210
  end
185
211
  Dawn::CLI::Env.set(data)
186
- when "unset"
187
- keys = options["<argv>"]
212
+ elsif options["unset"]
213
+ keys = options["<key_name>"]
188
214
  Dawn::CLI::Env.unset(*keys)
189
215
  else
190
- not_a_command("dawn env", command)
216
+ Dawn::CLI::Env.list
191
217
  end
192
218
  end
193
219
 
194
- def self.run_key_command(command, options)
195
- case command.to_s
196
- when ""
197
- Dawn::CLI::Key.list
198
- when "add"
220
+ def self.run_key_command(options)
221
+ if options["add"]
199
222
  Dawn::CLI::Key.add
200
- when "get"
201
- id = options["<argv>"].first
223
+ elsif options["get"]
224
+ id = options["<id>"].first
202
225
  Dawn::CLI::Key.get(id)
203
- when "delete"
204
- id = options["<argv>"].first
226
+ elsif options["delete"]
227
+ id = options["<id>"].first
205
228
  Dawn::CLI::Key.delete(id)
206
229
  else
207
- not_a_command("dawn env", command)
230
+ Dawn::CLI::Key.list
208
231
  end
209
232
  end
210
233
 
211
- def self.run_release_command(command, options)
212
- case command.to_s
213
- when ""
214
- Dawn::CLI::Release.list
215
- when "add"
234
+ def self.run_release_command(options)
235
+ if options["add"]
216
236
  Dawn::CLI::Release.add
217
237
  else
238
+ Dawn::CLI::Release.list
218
239
  not_a_command("dawn release", command)
219
240
  end
220
241
  end
221
242
 
243
+ ###
244
+ # @param [String] command
245
+ # @param [Array<String>] argv
246
+ ###
222
247
  def self.run_subcommand(command, argv)
223
248
  if argv.empty?
224
249
  subcommand = ""
225
250
  else
226
251
  result = Docopt.docopt(DOC_SUBCOMMAND[command], argv: argv,
227
- version: Dawn::CLI::VERSION, help: false)
228
- subcommand = result["<command>"]
252
+ version: Dawn::CLI::VERSION, help: true)
229
253
  end
230
- send("run_#{command}_command", subcommand, result)
254
+ send("run_#{command}_command", result)
231
255
  end
232
256
 
257
+ ###
258
+ # @param [Array<String>] argv
259
+ ###
233
260
  def self.run(argv)
234
- result = Docopt.docopt(DOC_TOP, version: Dawn::CLI::VERSION, argv: argv)
235
- if result["--version"]
236
- say "Dawn CLI #{Dawn::CLI::VERSION}"
261
+ # initial run to retrieve command
262
+ result = Docopt.docopt(DOC_TOP, argv: argv,
263
+ version: Dawn::CLI::VERSION, help: false)
264
+ command = result["<command>"]
265
+ # run the docopt again this time with help enabled if there was no command
266
+ unless command
267
+ result = Docopt.docopt(DOC_TOP, argv: argv,
268
+ version: Dawn::CLI::VERSION, help: true)
269
+ end
270
+
271
+ # set the selected_app
272
+ self.selected_app = result["--app"]
273
+ case command
274
+ when "create"
275
+ Dawn::CLI::App.create command_argv.first
276
+ when "ls"
277
+ Dawn::CLI::App.list
278
+ when "ps"
279
+ Dawn::CLI::App.list_gears
280
+ when "login"
281
+ username = ask("Username: ")
282
+ password = ask("Password: ") { |q| q.echo = false }
283
+ Dawn::CLI::Auth.login username, password
284
+ when "logs"
285
+ Dawn::CLI::App.logs
286
+ when *DOC_SUBCOMMAND.keys
287
+ run_subcommand(command, argv)
237
288
  else
238
- self.selected_app = result["--app"]
239
-
240
- command = result["<command>"]
241
- command_argv = result["<argv>"]
242
- case command
243
- when "create"
244
- Dawn::CLI::App.create command_argv.first
245
- when "ls"
246
- Dawn::CLI::App.list
247
- when "ps"
248
- Dawn::CLI::App.list_gears
249
- when "login"
250
- username = ask("Username: ")
251
- password = ask("Password: ") { |q| q.echo = false }
252
- Dawn::CLI::Auth.login username, password
253
- when "logs"
254
- Dawn::CLI::App.logs
255
- when *DOC_SUBCOMMAND.keys
256
- run_subcommand(command, command_argv)
257
- else
258
- not_a_command("dawn", command)
259
- end
289
+ not_a_command("dawn", command)
260
290
  end
261
291
  rescue Docopt::Exit => ex
262
292
  abort ex.message
@@ -3,7 +3,7 @@ module Dawn
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
- PATCH = 0
6
+ PATCH = 1
7
7
  BUILD = nil
8
8
  STRING = [[MAJOR, MINOR, PATCH].compact.join("."), BUILD].compact.join("-").freeze
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dawn-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blaž Hrastnik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-22 00:00:00.000000000 Z
12
+ date: 2014-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: docopt