Class: Podrb::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/podrb/cli.rb', line 12

def self.exit_on_failure?
  true
end

.start(given_args = ARGV, config = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/podrb/cli.rb', line 16

def self.start(given_args = ARGV, config = {})
  command = given_args.first
  does_not_require_config = %w[version -V --version init].include?(command)
  podrb_initialized = Dir.exist?(ENV["HOME"] + "/.config/podrb")
  if does_not_require_config || podrb_initialized
    super
  else
    puts "Missing config files. Run `podrb init` first."
  end
end

Instance Method Details

#add(feed) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/podrb/cli.rb', line 44

def add(feed)
  puts "Adding the podcast..."

  result = Podrb::Commands::Add::Runner.call(feed, options)

  puts Podrb::Commands::Add::Output.call(result)
end

#archive(episode_id) ⇒ Object



82
83
84
85
86
# File 'lib/podrb/cli.rb', line 82

def archive(episode_id)
  result = Podrb::Commands::Archive::Runner.call(episode_id)

  puts Podrb::Commands::Archive::Output.call(result)
end

#dearchive(episode_id) ⇒ Object



89
90
91
92
93
# File 'lib/podrb/cli.rb', line 89

def dearchive(episode_id)
  result = Podrb::Commands::Dearchive::Runner.call(episode_id)

  puts Podrb::Commands::Dearchive::Output.call(result)
end

#delete(podcast_id) ⇒ Object



96
97
98
99
100
# File 'lib/podrb/cli.rb', line 96

def delete(podcast_id)
  result = Podrb::Commands::Delete::Runner.call(podcast_id)

  puts Podrb::Commands::Delete::Output.call(result)
end

#episodes(podcast_id) ⇒ Object



64
65
66
67
68
# File 'lib/podrb/cli.rb', line 64

def episodes(podcast_id)
  result = Podrb::Commands::Episodes::Runner.call(podcast_id, options)

  puts Podrb::Commands::Episodes::Output.call(result)
end

#initObject



34
35
36
37
38
39
40
# File 'lib/podrb/cli.rb', line 34

def init
  puts "Creating config files..."

  result = Podrb::Commands::Init::Runner.call

  puts Podrb::Commands::Init::Output.call(result)
end

#open(episode_id) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/podrb/cli.rb', line 73

def open(episode_id)
  result = Podrb::Commands::Open::Runner.call(episode_id, options)

  Infrastructure::ShellInterface.call(result[:metadata])

  puts Podrb::Commands::Open::Output.call(result)
end

#podcastsObject



54
55
56
57
58
# File 'lib/podrb/cli.rb', line 54

def podcasts
  result = Podrb::Commands::Podcasts::Runner.call(options)

  puts Podrb::Commands::Podcasts::Output.call(result)
end

#sync(podcast_id) ⇒ Object



103
104
105
106
107
# File 'lib/podrb/cli.rb', line 103

def sync(podcast_id)
  result = Podrb::Commands::Sync::Runner.call(podcast_id)

  puts Podrb::Commands::Sync::Output.call(result)
end

#update(podcast_id) ⇒ Object



111
112
113
114
115
# File 'lib/podrb/cli.rb', line 111

def update(podcast_id)
  result = Podrb::Commands::Update::Runner.call(podcast_id, options)

  puts Podrb::Commands::Update::Output.call(result)
end

#versionObject



29
30
31
# File 'lib/podrb/cli.rb', line 29

def version
  puts VERSION
end