15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/wavesync/commands/set.rb', line 15
def run
subcommand = ARGV.shift
_options, config = parse_options(banner: 'Usage: wavesync set <subcommand> [options]')
case subcommand
when 'create'
name = require_name('create')
if Wavesync::Set.exists?(config.library, name)
puts "Set '#{name}' already exists. Use 'wavesync set edit #{name}' to edit it."
exit 1
end
set = Wavesync::Set.new(config.library, name)
Wavesync::SetEditor.new(set, config.library).run
when 'edit'
name = require_name('edit')
unless Wavesync::Set.exists?(config.library, name)
puts "Set '#{name}' not found. Use 'wavesync set create #{name}' to create it."
exit 1
end
set = Wavesync::Set.load(config.library, name)
Wavesync::SetEditor.new(set, config.library).run
when 'list'
sets = Wavesync::Set.all(config.library)
if sets.empty?
puts 'No sets found.'
else
sets.each { |set| puts "#{set.name} (#{set.tracks.size} tracks)" }
end
else
puts "Unknown subcommand: #{subcommand || '(none)'}"
puts 'Available subcommands: create, edit, list'
exit 1
end
end
|