buzzsprout-cli 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +271 -0
- data/bin/buzzsprout +6 -0
- data/lib/buzzsprout/animation/wordmark.rb +41 -0
- data/lib/buzzsprout/animation.rb +181 -0
- data/lib/buzzsprout/cli.rb +215 -0
- data/lib/buzzsprout/client.rb +306 -0
- data/lib/buzzsprout/color.rb +195 -0
- data/lib/buzzsprout/commands/base.rb +188 -0
- data/lib/buzzsprout/commands/brand_affiliations.rb +98 -0
- data/lib/buzzsprout/commands/chapters.rb +58 -0
- data/lib/buzzsprout/commands/contributors.rb +119 -0
- data/lib/buzzsprout/commands/downloads.rb +139 -0
- data/lib/buzzsprout/commands/episodes.rb +116 -0
- data/lib/buzzsprout/commands/fan_mail.rb +216 -0
- data/lib/buzzsprout/commands/feed_verifications.rb +74 -0
- data/lib/buzzsprout/commands/listings.rb +159 -0
- data/lib/buzzsprout/commands/login.rb +264 -0
- data/lib/buzzsprout/commands/podcasts.rb +85 -0
- data/lib/buzzsprout/commands/podrolls.rb +74 -0
- data/lib/buzzsprout/commands/skills.rb +144 -0
- data/lib/buzzsprout/commands/status.rb +64 -0
- data/lib/buzzsprout/commands/team.rb +75 -0
- data/lib/buzzsprout/commands/transcripts.rb +100 -0
- data/lib/buzzsprout/commands/update.rb +36 -0
- data/lib/buzzsprout/commands/uploads.rb +134 -0
- data/lib/buzzsprout/config.rb +125 -0
- data/lib/buzzsprout/formatter.rb +68 -0
- data/lib/buzzsprout/group_help.rb +74 -0
- data/lib/buzzsprout/oauth.rb +203 -0
- data/lib/buzzsprout/options.rb +155 -0
- data/lib/buzzsprout/podcast_picker.rb +328 -0
- data/lib/buzzsprout/redact.rb +65 -0
- data/lib/buzzsprout/updater.rb +230 -0
- data/lib/buzzsprout/version.rb +5 -0
- data/skills/README.md +62 -0
- data/skills/brand_affiliations/SKILL.md +52 -0
- data/skills/buzzsprout/SKILL.md +111 -0
- data/skills/chapters/SKILL.md +49 -0
- data/skills/contributors/SKILL.md +58 -0
- data/skills/episodes/SKILL.md +61 -0
- data/skills/fan_mail/SKILL.md +53 -0
- data/skills/feed_verifications/SKILL.md +51 -0
- data/skills/insertion_points/SKILL.md +50 -0
- data/skills/listings/SKILL.md +52 -0
- data/skills/podcasts/SKILL.md +57 -0
- data/skills/podrolls/SKILL.md +49 -0
- data/skills/soundbites/SKILL.md +51 -0
- data/skills/stats/SKILL.md +65 -0
- data/skills/team/SKILL.md +10 -0
- data/skills/transcripts/SKILL.md +60 -0
- data/skills/uploads/SKILL.md +68 -0
- metadata +102 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'io/console'
|
|
4
|
+
|
|
5
|
+
module Buzzsprout
|
|
6
|
+
module Commands
|
|
7
|
+
class Login < Base
|
|
8
|
+
USAGE = 'buzzsprout login [--no-animation] [--install-skills|--no-skills]'
|
|
9
|
+
HELP_PAGE = {
|
|
10
|
+
summary: 'Connect your Buzzsprout account in your browser.',
|
|
11
|
+
usage: 'buzzsprout login [--no-animation] [--install-skills|--no-skills]',
|
|
12
|
+
aliases: %w[login auth init],
|
|
13
|
+
flags: [
|
|
14
|
+
['--api-token', 'Use the API token prompt instead of browser login'],
|
|
15
|
+
['--no-browser', 'Print the authorization link without opening a browser'],
|
|
16
|
+
['--token TOKEN', 'Avoid: visible in process list and shell history. Prefer the prompt or BUZZSPROUT_API_TOKEN'],
|
|
17
|
+
['--no-animation', 'Skip the intro animation'],
|
|
18
|
+
['--install-skills', 'Install agent skills after login without prompting'],
|
|
19
|
+
['--no-skills', 'Skip the skills install prompt (--skip-skills)'],
|
|
20
|
+
['--dir PATH', 'Override detected agent skills directories']
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
'buzzsprout login',
|
|
24
|
+
'buzzsprout login --no-animation',
|
|
25
|
+
'buzzsprout login --install-skills'
|
|
26
|
+
]
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
29
|
+
def run
|
|
30
|
+
token_login = @args.delete('--api-token') || @options.token || !ENV['BUZZSPROUT_API_TOKEN'].to_s.empty?
|
|
31
|
+
return oauth_login unless token_login
|
|
32
|
+
|
|
33
|
+
play_intro
|
|
34
|
+
say_hello
|
|
35
|
+
|
|
36
|
+
loop do
|
|
37
|
+
token = acquire_token
|
|
38
|
+
if token.to_s.strip.empty?
|
|
39
|
+
@err.puts Color.red('A token is required. Find it in Buzzsprout under Profile → API.', io: @err)
|
|
40
|
+
next if retry?
|
|
41
|
+
return 1
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@io.puts 'Testing connection…'
|
|
45
|
+
@io.puts Color.dim('GET https://www.buzzsprout.com/api/podcasts', io: @io)
|
|
46
|
+
|
|
47
|
+
begin
|
|
48
|
+
client = Client.new(token: token.strip, dry_run: @options.dry_run?, io: @err)
|
|
49
|
+
podcasts = client.get('/podcasts') || []
|
|
50
|
+
persist(token.strip, podcasts)
|
|
51
|
+
celebrate(podcasts)
|
|
52
|
+
return 0
|
|
53
|
+
rescue Client::Unauthorized
|
|
54
|
+
@err.puts Color.red('That token was rejected (401).', io: @err)
|
|
55
|
+
@err.puts 'Open Buzzsprout → Profile → API and paste a fresh token.'
|
|
56
|
+
rescue Client::Error => e
|
|
57
|
+
@err.puts Color.red(e.message, io: @err)
|
|
58
|
+
rescue StandardError => e
|
|
59
|
+
@err.puts Color.red("Could not reach Buzzsprout: #{e.message}", io: @err)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
return 1 unless retry?
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def oauth_login
|
|
69
|
+
raise 'Login cannot run with --dry-run.' if @options.dry_run?
|
|
70
|
+
play_intro
|
|
71
|
+
say_hello(oauth: true)
|
|
72
|
+
open_browser = !@args.delete('--no-browser')
|
|
73
|
+
credentials = podcasts = nil
|
|
74
|
+
loop do
|
|
75
|
+
begin
|
|
76
|
+
credentials = OAuth.authorize(io: @io, open_browser: open_browser)
|
|
77
|
+
@io.puts 'Testing connection…'
|
|
78
|
+
@io.puts Color.dim("GET #{Config.api_base_url}/podcasts", io: @io)
|
|
79
|
+
podcasts = Client.new(token: credentials[:access_token], auth_scheme: 'Bearer').get('/podcasts') || []
|
|
80
|
+
break
|
|
81
|
+
rescue StandardError => e
|
|
82
|
+
@err.puts Color.red("Could not connect: #{e.message}", io: @err)
|
|
83
|
+
return 1 unless retry?(prompt: 'Retry browser login? [Y/n] ')
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
Config.with_lock do
|
|
87
|
+
Config.clear_cache
|
|
88
|
+
list = PodcastPicker.wrap_list(podcasts)
|
|
89
|
+
saved_id = Config.saved_podcast_id
|
|
90
|
+
saved_id = nil unless list.any? { |podcast| podcast['id'].to_s == saved_id.to_s }
|
|
91
|
+
default_id = @options.podcast_id || ENV['BUZZSPROUT_PODCAST_ID'] || saved_id || (list.first['id'] if list.size == 1)
|
|
92
|
+
Config.save(auth_method: 'oauth', oauth: credentials, api_token: nil, token: nil, default_podcast_id: default_id, podcast_id: nil)
|
|
93
|
+
end
|
|
94
|
+
celebrate(podcasts)
|
|
95
|
+
0
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def play_intro
|
|
99
|
+
return if @options.no_animation?
|
|
100
|
+
|
|
101
|
+
Animation.new(io: @io).play
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def say_hello(oauth: false)
|
|
105
|
+
@io.puts Color.bold('Welcome to the Buzzsprout CLI', io: @io)
|
|
106
|
+
@io.puts '=' * 40
|
|
107
|
+
if oauth
|
|
108
|
+
@io.puts 'Sign in to Buzzsprout in your browser to connect your account.'
|
|
109
|
+
else
|
|
110
|
+
@io.puts 'Authenticate with the token from Profile → API.'
|
|
111
|
+
@io.puts Color.dim('Tip: set BUZZSPROUT_API_TOKEN in the environment instead of pasting on argv.', io: @io)
|
|
112
|
+
end
|
|
113
|
+
@io.puts ''
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def acquire_token
|
|
117
|
+
return @options.token unless @options.token.to_s.empty?
|
|
118
|
+
return ENV['BUZZSPROUT_API_TOKEN'] unless ENV['BUZZSPROUT_API_TOKEN'].to_s.empty?
|
|
119
|
+
|
|
120
|
+
prompt_token
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def prompt_token
|
|
124
|
+
@io.print 'API token: '
|
|
125
|
+
@io.flush if @io.respond_to?(:flush)
|
|
126
|
+
token = if @stdin.respond_to?(:noecho) && @stdin.respond_to?(:tty?) && @stdin.tty?
|
|
127
|
+
@stdin.noecho(&:gets).to_s
|
|
128
|
+
else
|
|
129
|
+
@stdin.gets.to_s
|
|
130
|
+
end
|
|
131
|
+
@io.puts ''
|
|
132
|
+
token.strip
|
|
133
|
+
rescue StandardError
|
|
134
|
+
@stdin.gets.to_s.strip
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def persist(token, podcasts)
|
|
138
|
+
config = { api_token: token, auth_method: 'api_token', oauth: nil }
|
|
139
|
+
list = PodcastPicker.wrap_list(podcasts)
|
|
140
|
+
if (explicit = @options.podcast_id || ENV['BUZZSPROUT_PODCAST_ID'])
|
|
141
|
+
config[:default_podcast_id] = explicit
|
|
142
|
+
elsif list.size == 1
|
|
143
|
+
config[:default_podcast_id] = list.first['id']
|
|
144
|
+
end
|
|
145
|
+
Config.save(config)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def celebrate(podcasts)
|
|
149
|
+
@io.puts ''
|
|
150
|
+
@io.puts Color.rgb('Authentication Successful', Animation::BOLT_COLOR, io: @io)
|
|
151
|
+
list = PodcastPicker.wrap_list(podcasts)
|
|
152
|
+
@io.puts ''
|
|
153
|
+
@io.puts Color.dim("Token saved to #{Config.config_file} (mode 0600).", io: @io)
|
|
154
|
+
@io.puts ''
|
|
155
|
+
if list.empty?
|
|
156
|
+
@io.puts 'No podcasts on this account yet — create one in Buzzsprout, then run:'
|
|
157
|
+
@io.puts ' buzzsprout podcasts'
|
|
158
|
+
elsif list.size == 1
|
|
159
|
+
podcast = list.first
|
|
160
|
+
@io.puts "Default podcast: #{podcast['id']} #{podcast['title']}"
|
|
161
|
+
@io.puts ''
|
|
162
|
+
print_next_steps
|
|
163
|
+
else
|
|
164
|
+
pick_default_after_login(list)
|
|
165
|
+
end
|
|
166
|
+
offer_skills_install
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def pick_default_after_login(list)
|
|
170
|
+
if !@options.podcast_id.to_s.empty? || !ENV['BUZZSPROUT_PODCAST_ID'].to_s.empty?
|
|
171
|
+
print_podcast_list(list)
|
|
172
|
+
print_next_steps
|
|
173
|
+
return
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
unless interactive_podcast_picker?
|
|
177
|
+
print_podcast_list(list)
|
|
178
|
+
@io.puts 'Set a default with: buzzsprout podcast use'
|
|
179
|
+
print_next_steps
|
|
180
|
+
return
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
begin
|
|
184
|
+
chosen = PodcastPicker.choose!(
|
|
185
|
+
list,
|
|
186
|
+
io: @io,
|
|
187
|
+
stdin: @stdin,
|
|
188
|
+
default_id: Config.default_podcast_id,
|
|
189
|
+
auto_single: false
|
|
190
|
+
)
|
|
191
|
+
Config.save(default_podcast_id: chosen['id'])
|
|
192
|
+
@io.puts "Default podcast set to #{chosen['id']} #{chosen['title']}."
|
|
193
|
+
rescue PodcastPicker::Cancelled
|
|
194
|
+
@io.puts 'No default podcast set. Run `buzzsprout podcast use` when you are ready.'
|
|
195
|
+
end
|
|
196
|
+
print_next_steps
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def print_next_steps
|
|
200
|
+
@io.puts 'Try: buzzsprout podcasts'
|
|
201
|
+
@io.puts ' buzzsprout episodes list'
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def offer_skills_install
|
|
205
|
+
return if @options.dry_run?
|
|
206
|
+
|
|
207
|
+
destinations = Skills.destination_dirs(@options.dir)
|
|
208
|
+
if destinations.empty?
|
|
209
|
+
@io.puts 'To install agent skills, run: buzzsprout skills install --dir PATH' unless @options.skip_skills?
|
|
210
|
+
return
|
|
211
|
+
end
|
|
212
|
+
if @options.install_skills?
|
|
213
|
+
@io.puts ''
|
|
214
|
+
destinations.each { |dest| Skills.install_into!(dest, io: @io) }
|
|
215
|
+
return
|
|
216
|
+
end
|
|
217
|
+
return if @options.skip_skills?
|
|
218
|
+
return if destinations.all? { |dest| Skills.installed?(dest) }
|
|
219
|
+
return unless interactive_skills_prompt?
|
|
220
|
+
|
|
221
|
+
@io.puts ''
|
|
222
|
+
@io.puts 'Install or refresh skills in:'
|
|
223
|
+
destinations.each { |dest| @io.puts " #{dest}" }
|
|
224
|
+
@io.print 'Install agent skills now? [Y/n] '
|
|
225
|
+
@io.flush if @io.respond_to?(:flush)
|
|
226
|
+
answer = @stdin.gets.to_s.strip
|
|
227
|
+
if %w[n no].include?(answer.downcase)
|
|
228
|
+
@io.puts 'Skipped. Install later with: buzzsprout skills install'
|
|
229
|
+
return
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
destinations.each { |dest| Skills.install_into!(dest, io: @io) }
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def interactive_skills_prompt?
|
|
236
|
+
return false if @options.json?
|
|
237
|
+
return false if ENV['BUZZSPROUT_NONINTERACTIVE'] == '1'
|
|
238
|
+
return false unless @stdin.respond_to?(:tty?) && @stdin.tty?
|
|
239
|
+
|
|
240
|
+
true
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def print_podcast_list(list)
|
|
244
|
+
@io.puts Color.bold("#{list.size} podcast#{list.size == 1 ? '' : 's'} ready:", io: @io)
|
|
245
|
+
list.each do |podcast|
|
|
246
|
+
@io.puts " * #{podcast['id']} #{podcast['title']}"
|
|
247
|
+
end
|
|
248
|
+
@io.puts ''
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def retry?(prompt: 'Retry / re-enter token? [Y/n] ')
|
|
252
|
+
return false if ENV['BUZZSPROUT_NONINTERACTIVE'] == '1' || @options.json?
|
|
253
|
+
unless @stdin.respond_to?(:tty?) && @stdin.tty?
|
|
254
|
+
return false
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
@io.print prompt
|
|
258
|
+
answer = @stdin.gets.to_s.strip
|
|
259
|
+
answer.empty? || %w[y yes].include?(answer.downcase)
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Buzzsprout
|
|
4
|
+
module Commands
|
|
5
|
+
class Podcasts < Base
|
|
6
|
+
USAGE = 'buzzsprout podcasts [command] [flags]'
|
|
7
|
+
HELP_PAGE = {
|
|
8
|
+
summary: 'List, show, update, and select Buzzsprout podcasts.',
|
|
9
|
+
usage: 'buzzsprout podcasts <command> [flags]',
|
|
10
|
+
aliases: %w[podcasts podcast],
|
|
11
|
+
commands: [
|
|
12
|
+
['list', 'List podcasts (default)'],
|
|
13
|
+
['show <id>', 'Show podcast details'],
|
|
14
|
+
['update <id>', 'Update podcast metadata'],
|
|
15
|
+
['use [id]', 'Save a default podcast (picker if omitted)']
|
|
16
|
+
],
|
|
17
|
+
examples: [
|
|
18
|
+
'buzzsprout podcasts',
|
|
19
|
+
'buzzsprout podcast use',
|
|
20
|
+
'buzzsprout podcast use 10',
|
|
21
|
+
'buzzsprout podcasts show 10'
|
|
22
|
+
]
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
25
|
+
def run
|
|
26
|
+
verb, *rest = @args
|
|
27
|
+
case verb
|
|
28
|
+
when nil, 'list'
|
|
29
|
+
list
|
|
30
|
+
when 'show'
|
|
31
|
+
@args.replace(rest)
|
|
32
|
+
show
|
|
33
|
+
when 'update'
|
|
34
|
+
@args.replace(rest)
|
|
35
|
+
update
|
|
36
|
+
when 'use'
|
|
37
|
+
@args.replace(rest)
|
|
38
|
+
use_default
|
|
39
|
+
when /\A\d+\z/
|
|
40
|
+
@args.unshift(verb)
|
|
41
|
+
show
|
|
42
|
+
else
|
|
43
|
+
group_help
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def list
|
|
50
|
+
podcasts = client.get('/podcasts')
|
|
51
|
+
output(podcasts) { @formatter.list_podcasts(podcasts) }
|
|
52
|
+
0
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def show
|
|
56
|
+
id = shift_id!('podcast_id')
|
|
57
|
+
podcast = client.get("/podcasts/#{id}")
|
|
58
|
+
output(podcast) do
|
|
59
|
+
@formatter.show_record("Podcast #{podcast['id']}", podcast, %w[
|
|
60
|
+
id title author description website_address website_url contact_email
|
|
61
|
+
keywords explicit main_category sub_category language timezone
|
|
62
|
+
artwork_url rss_url
|
|
63
|
+
])
|
|
64
|
+
end
|
|
65
|
+
0
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def update
|
|
69
|
+
id = shift_id!('podcast_id')
|
|
70
|
+
body = @options.merge_body
|
|
71
|
+
raise 'Provide fields to update (--title, --body JSON, …)' if body.empty?
|
|
72
|
+
|
|
73
|
+
podcast = client.patch("/podcasts/#{id}", body: body)
|
|
74
|
+
output(podcast) { @io.puts "Updated podcast #{id}: #{podcast && podcast['title']}" }
|
|
75
|
+
0
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def use_default
|
|
79
|
+
id = resolve_podcast_id!(persist: true)
|
|
80
|
+
@io.puts "Default podcast set to #{id}."
|
|
81
|
+
0
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Buzzsprout
|
|
4
|
+
module Commands
|
|
5
|
+
class Podrolls < Base
|
|
6
|
+
USAGE = 'buzzsprout podrolls [command] [flags]'
|
|
7
|
+
HELP_PAGE = {
|
|
8
|
+
summary: 'Manage a podcast podroll.',
|
|
9
|
+
usage: 'buzzsprout podrolls <command> [id]',
|
|
10
|
+
aliases: %w[podrolls],
|
|
11
|
+
commands: [
|
|
12
|
+
['list', 'List podroll entries (default)'],
|
|
13
|
+
['create', 'Create an entry (--guid, --feed-url)'],
|
|
14
|
+
['update', 'Update an entry'],
|
|
15
|
+
['delete', 'Delete an entry']
|
|
16
|
+
],
|
|
17
|
+
examples: [
|
|
18
|
+
'buzzsprout podrolls',
|
|
19
|
+
'buzzsprout podrolls create --guid show-guid --feed-url https://example.com/feed.xml'
|
|
20
|
+
]
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
23
|
+
def run
|
|
24
|
+
verb = @args.shift || 'list'
|
|
25
|
+
case verb
|
|
26
|
+
when 'list' then list
|
|
27
|
+
when 'create' then create
|
|
28
|
+
when 'update' then update
|
|
29
|
+
when 'delete' then delete
|
|
30
|
+
else
|
|
31
|
+
group_help
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def list
|
|
38
|
+
podcast_id = podcast_id_from_args!
|
|
39
|
+
data = client.get("/#{podcast_id}/podrolls")
|
|
40
|
+
output(data) do
|
|
41
|
+
@formatter.heading("Podrolls for podcast #{podcast_id}")
|
|
42
|
+
Array(data).each { |row| @io.puts "#{row['id']} pos #{row['position']} #{row['feed_url']}" }
|
|
43
|
+
end
|
|
44
|
+
0
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def create
|
|
48
|
+
podcast_id = podcast_id_from_args!
|
|
49
|
+
body = @options.merge_body
|
|
50
|
+
raise 'guid and feed_url are required' if body['guid'].to_s.empty? || body['feed_url'].to_s.empty?
|
|
51
|
+
|
|
52
|
+
data = client.post("/#{podcast_id}/podrolls", body: body)
|
|
53
|
+
output(data) { @io.puts "Created podroll #{data && data['id']}" }
|
|
54
|
+
0
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def update
|
|
58
|
+
podcast_id = podcast_id_from_args!
|
|
59
|
+
id = shift_id!('id')
|
|
60
|
+
data = client.patch("/#{podcast_id}/podrolls/#{id}", body: @options.merge_body)
|
|
61
|
+
output(data) { @io.puts "Updated podroll #{id}" }
|
|
62
|
+
0
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def delete
|
|
66
|
+
podcast_id = podcast_id_from_args!
|
|
67
|
+
id = shift_id!('id')
|
|
68
|
+
data = client.delete("/#{podcast_id}/podrolls/#{id}")
|
|
69
|
+
output(data) { @io.puts "Deleted podroll #{id}" }
|
|
70
|
+
0
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'securerandom'
|
|
5
|
+
|
|
6
|
+
module Buzzsprout
|
|
7
|
+
module Commands
|
|
8
|
+
class Skills < Base
|
|
9
|
+
USAGE = 'buzzsprout skills [command] [flags]'
|
|
10
|
+
HELP_PAGE = {
|
|
11
|
+
summary: 'Install and list agent skills shipped with the CLI.',
|
|
12
|
+
usage: 'buzzsprout skills <command> [flags]',
|
|
13
|
+
aliases: %w[skills],
|
|
14
|
+
commands: [
|
|
15
|
+
['list', 'List bundled skills (default)'],
|
|
16
|
+
['path', 'Print the skills directory'],
|
|
17
|
+
['install', 'Copy skills into a local directory']
|
|
18
|
+
],
|
|
19
|
+
flags: [
|
|
20
|
+
['--dir PATH', 'Install destination (overrides detected Cursor/Claude Code directories)']
|
|
21
|
+
],
|
|
22
|
+
examples: [
|
|
23
|
+
'buzzsprout skills',
|
|
24
|
+
'buzzsprout skills install --dir ~/.cursor/skills'
|
|
25
|
+
]
|
|
26
|
+
}.freeze
|
|
27
|
+
|
|
28
|
+
def run
|
|
29
|
+
verb = @args.shift || 'list'
|
|
30
|
+
case verb
|
|
31
|
+
when 'list' then list
|
|
32
|
+
when 'path' then path
|
|
33
|
+
when 'install' then install
|
|
34
|
+
else
|
|
35
|
+
group_help
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.source_dir
|
|
40
|
+
File.expand_path('../../../../skills', __FILE__)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.bundled_skill_names
|
|
44
|
+
Dir.children(source_dir).sort.select { |name| File.directory?(File.join(source_dir, name)) }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.destination_dirs(explicit = nil, home: Dir.home)
|
|
48
|
+
override = explicit || ENV['BUZZSPROUT_SKILLS_DIR']
|
|
49
|
+
return [File.expand_path(override)] if override && !override.empty?
|
|
50
|
+
|
|
51
|
+
%w[.cursor .claude].filter_map do |agent|
|
|
52
|
+
root = File.join(home, agent)
|
|
53
|
+
File.join(root, 'skills') if File.directory?(root)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.installed_name(name)
|
|
58
|
+
name == 'buzzsprout' ? name : "buzzsprout-#{name.tr('_', '-')}"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.skill_identity(path)
|
|
62
|
+
return unless File.file?(path)
|
|
63
|
+
File.read(path).match(/\A---\n.*?^name: ([^\n]+).*?^---$/m)&.captures&.first&.strip
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.installed?(dest)
|
|
67
|
+
bundled_skill_names.all? do |name|
|
|
68
|
+
source = File.join(source_dir, name, 'SKILL.md')
|
|
69
|
+
target = File.join(dest, installed_name(name), 'SKILL.md')
|
|
70
|
+
File.file?(target) && File.binread(target) == File.binread(source)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.install_into!(dest, io: $stdout)
|
|
75
|
+
dest = File.expand_path(dest)
|
|
76
|
+
names = bundled_skill_names
|
|
77
|
+
names.each do |name|
|
|
78
|
+
target = File.join(dest, installed_name(name))
|
|
79
|
+
next unless File.exist?(target) || File.symlink?(target)
|
|
80
|
+
expected = skill_identity(File.join(source_dir, name, 'SKILL.md'))
|
|
81
|
+
unless !File.symlink?(target) && skill_identity(File.join(target, 'SKILL.md')) == expected
|
|
82
|
+
raise "Refusing to replace unrelated or symlinked skill: #{target}"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
FileUtils.mkdir_p(dest)
|
|
86
|
+
backup = File.join(File.dirname(dest), 'buzzsprout-skill-backups', "#{Time.now.utc.strftime('%Y%m%d%H%M%S')}-#{SecureRandom.hex(4)}")
|
|
87
|
+
names.each do |name|
|
|
88
|
+
src = File.join(source_dir, name)
|
|
89
|
+
target = File.join(dest, installed_name(name))
|
|
90
|
+
legacy = File.join(dest, name)
|
|
91
|
+
candidates = [target]
|
|
92
|
+
if legacy != target && !File.symlink?(legacy) && skill_identity(File.join(legacy, 'SKILL.md')) == skill_identity(File.join(src, 'SKILL.md'))
|
|
93
|
+
candidates << legacy
|
|
94
|
+
end
|
|
95
|
+
candidates.each do |path|
|
|
96
|
+
next unless File.exist?(path)
|
|
97
|
+
FileUtils.mkdir_p(backup)
|
|
98
|
+
FileUtils.mv(path, File.join(backup, File.basename(path)))
|
|
99
|
+
end
|
|
100
|
+
FileUtils.cp_r(src, target)
|
|
101
|
+
end
|
|
102
|
+
io.puts "Installed #{names.size} skills into #{dest}:"
|
|
103
|
+
names.each { |name| io.puts " #{installed_name(name)}" }
|
|
104
|
+
io.puts "Previous skills saved in #{backup}" if File.directory?(backup)
|
|
105
|
+
names
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
private
|
|
109
|
+
|
|
110
|
+
def source_dir
|
|
111
|
+
self.class.source_dir
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def list
|
|
115
|
+
skills = self.class.bundled_skill_names
|
|
116
|
+
payload = { path: source_dir, skills: skills }
|
|
117
|
+
output(payload) do
|
|
118
|
+
@formatter.heading('Agent skills')
|
|
119
|
+
@io.puts source_dir
|
|
120
|
+
@io.puts ''
|
|
121
|
+
skills.each { |name| @io.puts " #{name}" }
|
|
122
|
+
@io.puts ''
|
|
123
|
+
@io.puts 'Install into a local skills directory:'
|
|
124
|
+
@io.puts ' buzzsprout skills install'
|
|
125
|
+
@io.puts ' buzzsprout skills install --dir ~/.claude/skills'
|
|
126
|
+
end
|
|
127
|
+
0
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def path
|
|
131
|
+
@io.puts source_dir
|
|
132
|
+
0
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def install
|
|
136
|
+
dest = @options.dir || Options.extract_option!(@args, '--dir')
|
|
137
|
+
destinations = self.class.destination_dirs(dest)
|
|
138
|
+
raise 'No supported agent directory found. Use --dir PATH to choose a skills directory.' if destinations.empty?
|
|
139
|
+
destinations.each { |directory| self.class.install_into!(directory, io: @io) }
|
|
140
|
+
0
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Buzzsprout
|
|
4
|
+
module Commands
|
|
5
|
+
class Logout < Base
|
|
6
|
+
USAGE = 'buzzsprout logout'
|
|
7
|
+
HELP_PAGE = {
|
|
8
|
+
summary: 'Disconnect and remove saved credentials and the default podcast.',
|
|
9
|
+
usage: 'buzzsprout logout [--local-only]',
|
|
10
|
+
flags: [['--local-only', 'Forget saved credentials without revoking the OAuth connection']],
|
|
11
|
+
aliases: %w[logout],
|
|
12
|
+
examples: ['buzzsprout logout']
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
Config.with_lock do
|
|
17
|
+
Config.clear_cache
|
|
18
|
+
credentials = Config.loaded[:oauth]
|
|
19
|
+
OAuth.revoke(credentials) if credentials && !@args.delete('--local-only')
|
|
20
|
+
Config.delete!
|
|
21
|
+
end
|
|
22
|
+
@io.puts "Logged out. Removed #{Config.config_file}."
|
|
23
|
+
0
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Status < Base
|
|
28
|
+
USAGE = 'buzzsprout status'
|
|
29
|
+
HELP_PAGE = {
|
|
30
|
+
summary: 'Show whether a token and default podcast are saved.',
|
|
31
|
+
usage: 'buzzsprout status',
|
|
32
|
+
aliases: %w[status whoami],
|
|
33
|
+
examples: ['buzzsprout status']
|
|
34
|
+
}.freeze
|
|
35
|
+
|
|
36
|
+
def run
|
|
37
|
+
if Config.configured?
|
|
38
|
+
payload = {
|
|
39
|
+
authenticated: true,
|
|
40
|
+
auth_method: Config.oauth? ? 'oauth' : 'api_token',
|
|
41
|
+
token_set: true,
|
|
42
|
+
config_file: Config.config_file,
|
|
43
|
+
default_podcast_id: Config.default_podcast_id,
|
|
44
|
+
api_base: Config.api_base_url,
|
|
45
|
+
user_agent: Client::USER_AGENT
|
|
46
|
+
}
|
|
47
|
+
output(payload) do
|
|
48
|
+
@io.puts Color.green('Authenticated', io: @io)
|
|
49
|
+
@formatter.kv('Config', Config.config_file)
|
|
50
|
+
@formatter.kv('Method', Config.oauth? ? 'OAuth' : 'API token')
|
|
51
|
+
@formatter.kv('Podcast', Config.default_podcast_id)
|
|
52
|
+
@formatter.kv('API', Config.api_base_url)
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
payload = { authenticated: false, token_set: false, config_file: Config.config_file }
|
|
56
|
+
output(payload) do
|
|
57
|
+
@io.puts 'Not authenticated. Run `buzzsprout login`.'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
0
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|