zillabyte-cli 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ class Zillabyte::Command::Auth < Zillabyte::Command::Base
10
10
 
11
11
  # auth:login
12
12
  #
13
- # Sets the Zillabyte Auth token
13
+ # sets the Zillabyte auth token
14
14
  #
15
15
  # --auth_token TOKEN # provide the token
16
16
  def login
@@ -25,7 +25,7 @@ class Zillabyte::Command::Auth < Zillabyte::Command::Base
25
25
 
26
26
  # auth:logout
27
27
  #
28
- # Sets the Zillabyte Auth token
28
+ # sets the Zillabyte auth token
29
29
  #
30
30
  def logout
31
31
  Zillabyte::Auth.logout
@@ -19,7 +19,7 @@ module Zillabyte
19
19
  conf_file = File.join(dir, options[:config_file] || DEFAULT_CONFIG_FILE)
20
20
  end
21
21
  type = options[:type]
22
-
22
+
23
23
  return nil unless File.exists?(conf_file)
24
24
  hash = YAML.load_file(conf_file)
25
25
 
@@ -31,6 +31,7 @@ module Zillabyte
31
31
  top_dir = File.expand_path(hash['top_dir'] || ".", dir)
32
32
  top_path = Pathname.new(top_dir)
33
33
  rel_dir = Pathname.new(dir).relative_path_from(top_path).to_s
34
+
34
35
  ignore_files = if hash.has_key?("ignore_files")
35
36
  ignore_files = hash["ignore_files"]
36
37
  ignore_files_array = ignore_files.respond_to?(:to_a) ? ignore_files.to_a() : [ignore_files]
@@ -6,7 +6,7 @@ class Zillabyte::Command::Help < Zillabyte::Command::Base
6
6
 
7
7
  PRIMARY_NAMESPACES = %w( relations query apps logs )
8
8
 
9
-
9
+ # help
10
10
  def index(*direct_args)
11
11
 
12
12
  if command = args.shift || direct_args.shift
@@ -45,6 +45,7 @@ private
45
45
  end
46
46
 
47
47
  def legacy_help_for_command(command)
48
+
48
49
  Zillabyte::Command::Help.groups.each do |group|
49
50
  group.each do |cmd, description|
50
51
  return description if cmd.split(" ").first == command
@@ -90,7 +91,7 @@ private
90
91
  if command_alias.include?("-") or command_alias.include?(":")
91
92
  next #skip -h, -help and live-run etc.
92
93
  end
93
- puts command_alias.ljust(a_size) + " --> " + alias_to.ljust(a_to_size) + " # " + commands[alias_to][:summary]
94
+ puts "#{command_alias.ljust(a_size)} --> #{alias_to.ljust(a_to_size)} # #{commands[alias_to][:summary]}"
94
95
  end
95
96
  end
96
97
 
@@ -0,0 +1,42 @@
1
+ require "zillabyte/cli/base"
2
+ require "zillabyte/cli/config"
3
+ require "zillabyte/common"
4
+
5
+
6
+ # HIDDEN: resets all user state
7
+ #
8
+ class Zillabyte::Command::Nuke < Zillabyte::Command::Base
9
+
10
+
11
+
12
+
13
+ # apps:nuke
14
+ #
15
+ # destroys all state associated with the current user
16
+ #
17
+ # --force # this option must always be given
18
+ #
19
+ def index
20
+
21
+ unless options[:force]
22
+ fail("--force must be given")
23
+ raise
24
+ end
25
+
26
+ res = api.request(
27
+ :expects => 200,
28
+ :method => :post,
29
+ :path => "/nukes",
30
+ :body => options.to_json
31
+ )
32
+ res.body
33
+
34
+ if options[:type] == "json"
35
+ display res.body.to_json
36
+ else
37
+ display "Nuked #{res.body['deleted_apps']} app(s) and #{res.body['deleted_apps']} relations(s)"
38
+ end
39
+
40
+
41
+ end
42
+ end
@@ -11,7 +11,7 @@ require "json"
11
11
  class Zillabyte::Command::Relations < Zillabyte::Command::Base
12
12
 
13
13
  MAX_POLL_SECONDS = 60 * 5
14
- POLL_SLEEP = 0.5
14
+ POLL_SLEEP = 1
15
15
 
16
16
  # relations
17
17
  #
@@ -87,7 +87,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
87
87
  error(res['error'], type)
88
88
  else
89
89
  if type == "json"
90
- display {}.to_json
90
+ display "{}"
91
91
  else
92
92
  display res["body"]
93
93
  end
@@ -119,7 +119,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
119
119
  error("no name given", type) if name.nil?
120
120
 
121
121
  schema = options[:schema] if options[:schema]
122
- is_public = options[:public] || nil
122
+ is_public = options[:public] || false
123
123
  description = options[:description] || nil
124
124
  aliases = options[:aliases] || nil
125
125
 
@@ -140,7 +140,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
140
140
  error("#{res['error_message']}", type)
141
141
  else
142
142
  if type == "json"
143
- display {}.to_json
143
+ display "{}"
144
144
  else
145
145
  display "relation ##{res['id']} #{res['action']}. size: #{res['size'] || 0} rows."
146
146
  end
@@ -174,7 +174,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
174
174
 
175
175
  res = self.api.data.append(id, options.merge({:rows => rows}))
176
176
  if type == "json"
177
- display {}.to_json
177
+ display "{}"
178
178
  else
179
179
  display "relation ##{id} appended #{res["size"]} rows"
180
180
  end
@@ -234,7 +234,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
234
234
  end
235
235
 
236
236
  if type == "json"
237
- display {}.to_json
237
+ display "{}"
238
238
  else
239
239
  display "pulled data from relation ##{id} to file #{file}"
240
240
  end
@@ -272,7 +272,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
272
272
  res = self.api.data.pull_to_s3(id, s3_params)
273
273
 
274
274
  if type == "json"
275
- display {}.to_json
275
+ display "{}"
276
276
  else
277
277
  display "downloading relation data to s3://#{res["s3_bucket"]}/#{res["s3_file_key"]}/"
278
278
  display "if the relation is large, this may take a while, please check your s3 account after a few minutes"
@@ -372,7 +372,7 @@ class Zillabyte::Command::Relations < Zillabyte::Command::Base
372
372
  display TableOutputBuilder.build_table(headings, rows, type)
373
373
  else
374
374
  if type == "json"
375
- display {}.to_json
375
+ display "{}"
376
376
  else
377
377
  display "empty relation"
378
378
  end
@@ -1,22 +1,43 @@
1
1
  require "zillabyte/cli/base"
2
-
2
+ require 'readline'
3
3
  # REPL console for zillabyte commands
4
4
  #
5
5
  class Zillabyte::Command::Repl < Zillabyte::Command::Base
6
6
 
7
7
  # repl
8
8
  #
9
- # Start a console session for zillabyte
10
- #
9
+ # start a console session for zillabyte
10
+ # --quiet # HIDDEN
11
+ # --history HISTORY# HIDDEN hack to allow history for readline
11
12
  def index
12
-
13
- while true
14
-
15
- display "zilla> ", false
16
- cmd = ask
17
- exec "zillabyte #{cmd}; zillabyte repl"
18
-
13
+ if !options[:quiet]
14
+ v = `zillabyte version`
15
+ display "\n#{v}Type q,exit or Ctrl+D to quit\n\n"
16
+ end
17
+ server = `echo $ZILLABYTE_API_HOST` || ""
18
+ prompt = ""
19
+ if server && server.chomp.length > 0
20
+ prompt = "#{server.chomp} "
21
+ end
22
+ prompt += "zillabyte $ "
23
+ if options[:history]
24
+ #p options[:history]
25
+ history = JSON.parse(options[:history])
26
+ history.last(50).each do |his|
27
+ # TODO: Handle single quotes ??
28
+ Readline::HISTORY << his
19
29
  end
20
-
30
+ end
31
+ # TODO: Add tab completion for basic commands, app/relation names etc.
32
+ while cmd = Readline.readline(prompt, true)
33
+ if cmd && cmd.length > 0
34
+ if cmd.downcase == "exit" || cmd.downcase == "q"
35
+ display "" # TODO Make Ctrl+D print a newline too
36
+ return
37
+ else
38
+ exec "zillabyte #{cmd}; zillabyte repl --quiet --history '#{Readline::HISTORY.to_a.to_json}'"
39
+ end
40
+ end
41
+ end
21
42
  end
22
43
  end
@@ -0,0 +1,81 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionpack (3.2.17)
5
+ activemodel (= 3.2.17)
6
+ activesupport (= 3.2.17)
7
+ builder (~> 3.0.0)
8
+ erubis (~> 2.7.0)
9
+ journey (~> 1.0.4)
10
+ rack (~> 1.4.5)
11
+ rack-cache (~> 1.2)
12
+ rack-test (~> 0.6.1)
13
+ sprockets (~> 2.2.1)
14
+ activemodel (3.2.17)
15
+ activesupport (= 3.2.17)
16
+ builder (~> 3.0.0)
17
+ activesupport (3.2.17)
18
+ i18n (~> 0.6, >= 0.6.4)
19
+ multi_json (~> 1.0)
20
+ ascii_charts (0.9.1)
21
+ aws-sdk (1.33.0)
22
+ json (~> 1.4)
23
+ nokogiri (>= 1.4.4)
24
+ uuidtools (~> 2.1)
25
+ builder (3.0.4)
26
+ chronic (0.10.2)
27
+ colorize (0.7.2)
28
+ erubis (2.7.0)
29
+ excon (0.33.0)
30
+ hike (1.2.3)
31
+ i18n (0.6.9)
32
+ indentation (0.1.1)
33
+ journey (1.0.4)
34
+ json (1.8.1)
35
+ mime-types (2.2)
36
+ mini_portile (0.5.3)
37
+ multi_json (1.9.2)
38
+ netrc (0.7.7)
39
+ nokogiri (1.6.1)
40
+ mini_portile (~> 0.5.0)
41
+ rack (1.4.5)
42
+ rack-cache (1.2)
43
+ rack (>= 0.4)
44
+ rack-test (0.6.2)
45
+ rack (>= 1.0)
46
+ rest-client (1.6.7)
47
+ mime-types (>= 1.16)
48
+ sprockets (2.2.2)
49
+ hike (~> 1.2)
50
+ multi_json (~> 1.0)
51
+ rack (~> 1.0)
52
+ tilt (~> 1.1, != 1.3.0)
53
+ terminal-table (1.4.5)
54
+ tilt (1.4.1)
55
+ time_difference (0.3.2)
56
+ activesupport
57
+ uuidtools (2.1.4)
58
+ zillabyte (0.0.20)
59
+ zillabyte-cli (~> 0.0.20)
60
+ zillabyte-cli (0.0.20)
61
+ actionpack (~> 3.2.13)
62
+ activesupport (~> 3.2.11)
63
+ ascii_charts (~> 0.9.1)
64
+ aws-sdk (~> 1.33.0)
65
+ bundler (~> 1.3)
66
+ chronic (~> 0.10)
67
+ colorize (~> 0.6)
68
+ excon (~> 0.31)
69
+ indentation (~> 0.1)
70
+ mini_portile (~> 0.5.0)
71
+ multi_json (~> 1.0)
72
+ netrc (~> 0.7.7)
73
+ rest-client (~> 1.6.1)
74
+ terminal-table (~> 1.4)
75
+ time_difference
76
+
77
+ PLATFORMS
78
+ ruby
79
+
80
+ DEPENDENCIES
81
+ zillabyte
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'zillabyte'
5
5
 
6
- app = Zillabyte.app("hello_world_app")
6
+ Zillabyte.app("hello_world_app")
7
7
  .source("select * from web_pages")
8
8
  .each{ |page|
9
9
  if page['html'].include? "hello world"
@@ -13,4 +13,4 @@ app = Zillabyte.app("hello_world_app")
13
13
  .sink{
14
14
  name "has_hello_world"
15
15
  column "url", :string
16
- }
16
+ }
@@ -4,8 +4,15 @@ require "zillabyte/cli/base"
4
4
  #
5
5
  class Zillabyte::Command::Version < Zillabyte::Command::Base
6
6
 
7
+ # version
8
+ #
9
+ # display version number of the CLI
7
10
  def index(*direct_args)
8
- display "Zillabyte CLI Version #{Zillabyte::CLI::VERSION}"
11
+ if options[:type] == "json"
12
+ display( {:version => Zillabyte::CLI::VERSION}.to_json )
13
+ else
14
+ display "Zillabyte CLI Version #{Zillabyte::CLI::VERSION}"
15
+ end
9
16
  end
10
17
 
11
18
  end
@@ -165,10 +165,16 @@ module Zillabyte
165
165
 
166
166
  args.concat(invalid_options)
167
167
 
168
+ # Make the --json command universal..
169
+ if invalid_options.include?("--json")
170
+ invalid_options.delete("--json")
171
+ opts[:type] = "json"
172
+ end
173
+
168
174
  @current_args = args
169
175
  @current_options = opts
170
176
  @invalid_arguments = invalid_options
171
-
177
+
172
178
  @anonymous_command = [ARGV.first, *@anonymized_args].join(' ')
173
179
  begin
174
180
  usage_directory = "#{home_directory}/.zillabyte/usage"
@@ -17,11 +17,12 @@ module Zillabyte
17
17
 
18
18
  def error(message, format=nil)
19
19
  if format == "json"
20
- $stderr.puts(({"error"=>message}).to_json)
20
+ $stdout.puts(({"error"=>message}).to_json)
21
+ exit
21
22
  else
22
23
  $stderr.puts(format_with_bang(message))
24
+ exit(1)
23
25
  end
24
- exit(1)
25
26
  end
26
27
 
27
28
  def format_with_bang(message)
@@ -1,5 +1,5 @@
1
1
  module Zillabyte
2
2
  module CLI
3
- VERSION = "0.0.20"
3
+ VERSION = "0.0.21"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zillabyte-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - zillabyte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -257,6 +257,7 @@ files:
257
257
  - lib/zillabyte/api.rb
258
258
  - lib/zillabyte/auth.rb
259
259
  - lib/zillabyte/cli/apps.rb
260
+ - lib/zillabyte/cli/apps.rb.orig
260
261
  - lib/zillabyte/cli/auth.rb
261
262
  - lib/zillabyte/cli/base.rb
262
263
  - lib/zillabyte/cli/config.rb
@@ -266,6 +267,7 @@ files:
266
267
  - lib/zillabyte/cli/helpers/table_output_builder.rb
267
268
  - lib/zillabyte/cli/host.rb
268
269
  - lib/zillabyte/cli/log_formatter.rb
270
+ - lib/zillabyte/cli/nuke.rb
269
271
  - lib/zillabyte/cli/query.rb
270
272
  - lib/zillabyte/cli/relations.rb
271
273
  - lib/zillabyte/cli/repl.rb
@@ -277,6 +279,7 @@ files:
277
279
  - lib/zillabyte/cli/templates/python/zillabyte.conf.yaml
278
280
  - lib/zillabyte/cli/templates/ruby/app.rb
279
281
  - lib/zillabyte/cli/templates/ruby/Gemfile
282
+ - lib/zillabyte/cli/templates/ruby/Gemfile.lock
280
283
  - lib/zillabyte/cli/templates/ruby/zillabyte.conf.yaml
281
284
  - lib/zillabyte/cli/version.rb
282
285
  - lib/zillabyte/cli/zillalogs.rb