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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/ruby_spriter/cli.rb', line 19
def parse_and_run(args)
options = {}
options[:fuzzy_select] = false
if args.include?('--help') || args.include?('-h')
handle_context_sensitive_help(args)
end
parser = build_option_parser(options)
parser.parse!(args)
if options[:check_dependencies]
checker = DependencyChecker.new(verbose: true)
checker.print_report
exit(checker.all_satisfied? ? 0 : 1)
end
if options[:extract] && options[:split]
raise ValidationError, "--extract and --split are mutually exclusive"
end
if options[:add_meta] && (options[:scale_percent] || options[:remove_bg] || options[:sharpen])
raise ValidationError, "--add-meta cannot be combined with processing options (--scale, --remove-bg, --sharpen)"
end
if options[:by_frame]
unless options[:remove_bg]
raise ValidationError, "--by-frame requires --remove-bg"
end
unless options[:video] || options[:batch]
raise ValidationError, "--by-frame requires --video or --batch"
end
end
if options[:cleanup_cells]
unless options[:remove_bg]
raise ValidationError, "--cleanup-cells requires --remove-bg flag"
end
if options[:by_frame]
raise ValidationError, "--cleanup-cells cannot be used with --by-frame (redundant)"
end
unless options[:video] || options[:batch]
raise ValidationError, "--cleanup-cells requires --video or --batch mode"
end
if options[:cell_cleanup_threshold]
unless options[:cell_cleanup_threshold].between?(1.0, 50.0)
raise ValidationError, "--cell-cleanup-threshold must be between 1.0 and 50.0"
end
end
end
processor = Processor.new(options)
processor.run
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
puts "Error: #{e.message}"
puts "\nUse --help for usage information"
exit 1
end
|