zencoder-cli 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,12 @@
1
1
  module Zencoder::CLI::Command
2
2
  class Account < Base
3
3
 
4
- provides "account", { "account:show" => "Show account information",
5
- "account:integration" => "Put your account in integration mode",
6
- "account:live" => "Take your account out of integration mode" }
7
-
4
+ provides "account", "account" => "Show account information",
5
+ "account:integration" => "Put your account in integration mode",
6
+ "account:live" => "Take your account out of integration mode"
8
7
  class << self
9
8
 
10
- def show(args, global_options, command_options)
9
+ def run(args, global_options, command_options)
11
10
  account = Zencoder::Account.details(:base_url => Zencoder.base_url(global_options[:environment])).body
12
11
  rows = []
13
12
  rows << ["Minutes Used", account["minutes_used"]]
@@ -1,20 +1,15 @@
1
1
  module Zencoder::CLI::Command
2
- class Jobs < Base
3
-
4
- provides "jobs", { "jobs:list" => { :description => "Lists the most recent jobs",
5
- :options => proc{|t|
6
- t.opt :number, "Number of jobs returned per page. Default 10.", :type => Integer
7
- t.opt :page, "Jobs page number. Default 1.", :type => Integer
8
- t.opt :long, "Will not truncate filenames.", :default => false
9
- }},
10
- "jobs:show" => "Show job details by ID",
11
- "jobs:resubmit" => "Resubmit a job by ID",
12
- "jobs:cancel" => "Cancels a job by ID",
13
- "jobs:delete" => "Deletes a job by ID" }
14
2
 
3
+ class Jobs < Base
4
+ provides "jobs", "jobs" => { :description => "Lists the most recent jobs",
5
+ :options => proc{|t|
6
+ t.opt :number, "Number of jobs returned per page. Default 10.", :type => Integer
7
+ t.opt :page, "Jobs page number. Default 1.", :type => Integer
8
+ t.opt :long, "Will not truncate filenames.", :default => false
9
+ }}
15
10
  class << self
16
11
 
17
- def list(args, global_options, command_options)
12
+ def run(args, global_options, command_options)
18
13
  jobs = Zencoder::Job.list(:base_url => Zencoder.base_url(global_options[:environment]), :per_page => command_options[:number] || 10, :page => command_options[:page] || 1).process_for_cli.body
19
14
  if jobs.any?
20
15
  jobs_table = table do |t|
@@ -39,8 +34,21 @@ module Zencoder::CLI::Command
39
34
  end
40
35
  end
41
36
 
42
- def show(args, global_options, command_options)
43
- job = Zencoder::Job.details(args.shift, :base_url => Zencoder.base_url(global_options[:environment])).process_for_cli.body["job"]
37
+ end
38
+ end
39
+
40
+
41
+ class Job < Base
42
+ provides "job", "job" => { :description => "Show job details by ID", :help => "" },
43
+ "job:open" => "Opens the job in the dashboard",
44
+ "job:resubmit" => "Resubmit a job by ID",
45
+ "job:cancel" => "Cancels a job by ID",
46
+ "job:delete" => "Deletes a job by ID"
47
+ class << self
48
+
49
+ def run(args, global_options, command_options)
50
+ job_id = extract_job_id(args)
51
+ job = Zencoder::Job.details(job_id, :base_url => Zencoder.base_url(global_options[:environment])).process_for_cli.body["job"]
44
52
  rows = []
45
53
  rows << ["ID", job["id"]]
46
54
  rows << ["Created", format_date(job["created_at"])]
@@ -110,24 +118,41 @@ module Zencoder::CLI::Command
110
118
  end
111
119
  end
112
120
 
121
+ def open(args, global_options, command_options)
122
+ job_id = extract_job_id(args)
123
+ `open https://app.zencoder.com/jobs/#{job_id}`
124
+ end
125
+
113
126
  def resubmit(args, global_options, command_options)
114
- job_id = args.shift
127
+ job_id = extract_job_id(args)
115
128
  response = Zencoder::Job.resubmit(job_id, :base_url => Zencoder.base_url(global_options[:environment])).process_for_cli
116
129
  puts "Job ##{job_id} resubmitted."
117
130
  end
118
131
 
119
132
  def cancel(args, global_options, command_options)
120
- job_id = args.shift
133
+ job_id = extract_job_id(args)
121
134
  response = Zencoder::Job.cancel(job_id, :base_url => Zencoder.base_url(global_options[:environment])).process_for_cli
122
135
  puts "Job ##{job_id} cancelled."
123
136
  end
124
137
 
125
138
  def delete(args, global_options, command_options)
126
- job_id = args.shift
139
+ job_id = extract_job_id(args)
127
140
  response = Zencoder::Job.delete(job_id, :base_url => Zencoder.base_url(global_options[:environment])).process_for_cli
128
141
  puts "Job ##{job_id} deleted."
129
142
  end
130
143
 
144
+
145
+ private
146
+
147
+ def extract_job_id(args)
148
+ job_id = args.shift
149
+ if !job_id.to_s.strip[/^\d+$/]
150
+ puts "You must specify the job to show. Try `zencoder jobs:show --help` for more information."
151
+ exit 1
152
+ end
153
+ job_id
154
+ end
131
155
  end
156
+
132
157
  end
133
158
  end
@@ -1,7 +1,7 @@
1
1
  module Zencoder::CLI::Command
2
- class Outputs < Base
2
+ class Output < Base
3
3
 
4
- provides "outputs", { "outputs:progress" => "Show output progress" }
4
+ provides "output", "output:progress" => "Show output progress"
5
5
 
6
6
  class << self
7
7
 
@@ -19,5 +19,6 @@ module Zencoder::CLI::Command
19
19
  end
20
20
 
21
21
  end
22
+
22
23
  end
23
24
  end
@@ -1,13 +1,13 @@
1
1
  module Zencoder::CLI::Command
2
2
  class Plugins < Base
3
3
 
4
- provides "plugins", { "plugins:list" => "Lists installed plugins",
5
- "plugins:install" => "Install a plugin via URL",
6
- "plugins:uninstall" => "Uninstall a plugin" }
4
+ provides "plugins", "plugins" => "Lists installed plugins",
5
+ "plugins:install" => "Install a plugin via URL",
6
+ "plugins:uninstall" => "Uninstall a plugin"
7
7
 
8
8
  class << self
9
9
 
10
- def list(args, global_options, command_options)
10
+ def run(args, global_options, command_options)
11
11
  if Zencoder::CLI::Plugin.list.any?
12
12
  puts "The following plugins are installed:"
13
13
  Zencoder::CLI::Plugin.list.each do |plugin|
@@ -4,9 +4,9 @@ require 'yaml'
4
4
  module Zencoder::CLI::Command
5
5
  class Setup < Base
6
6
 
7
- provides "setup", { "setup" => "Caches authentication credentials",
8
- "setup:show" => "Shows your API keys",
9
- "setup:delete" => "Removes cached credentials and plugins" }
7
+ provides "setup", "setup" => "Caches authentication credentials",
8
+ "setup:show" => "Shows your API keys",
9
+ "setup:delete" => "Removes cached credentials and plugins"
10
10
 
11
11
  class << self
12
12
 
@@ -1,5 +1,5 @@
1
1
  module Zencoder
2
2
  module CLI
3
- GEM_VERSION = '0.1.1'
3
+ GEM_VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zencoder-cli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Arbini
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-17 00:00:00 -06:00
18
+ date: 2010-11-18 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency