14
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
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/lgtm_hd/cli.rb', line 14
def run
program :name, LgtmHD::Configuration::PROGRAM_NAME
program :version, LgtmHD::VERSION
program :description, LgtmHD::Configuration::DESCRIPTION
default_command :export
command :transform do |c|
c.syntax = 'lgtm_hd transform <source_uri> <output_uri> [options]'
c.summary = 'Generate a LGTM image from source_uri (local path or URL) into output_uri (local)'
c.description = ''
c.example '', 'lgtm_hd export http://domain.com/image.png /path/to/lgtm.png'
c.option '--clipboard', 'Copy the end result (LGTM image) to OS\'s clipboard'
c.action do |args, options|
uri = URI.parse(args[0])
tmp_file_name = Time.now.strftime('%Y-%m-%d_%H-%M-%S') << LgtmHD::Configuration::TEMP_FILE_PREFIX
meme_generator = MemeGenerator.new(*args)
meme_generator.draw
meme_generator.export do |output|
say "LGTM image has been generated at #{output}."
if not options.clipboard then return; end
if OS.mac? then
applescript "set the clipboard to (read (POSIX file \"#{output}\") as GIF picture)"
say "I see you are using MacOSX. Content of the file has been copied to your clipboard."
else
Clipboard.copy(output)
say "Path to LGTM file has been copied to your clipboard."
end
end
end
end
run!
end
|