|
58 | 58 |
|
59 | 59 | script_file = nil
|
60 | 60 | version = {{ read_file("./shard.yml").split("\n")[1][9..] }}
|
61 |
| -if ARGV[0]? |
62 |
| - if ARGV[0] == "-v" || ARGV[0] == "--version" |
63 |
| - puts "AHK_X11 version: #{version}\nTargets to partially implement Classic Windows AutoHotkey specification: v1.0.24 (2004). AutoHotkey is a scripting language." |
64 |
| - ::exit |
65 |
| - elsif ARGV[0] == "-h" || ARGV[0] == "--help" |
66 |
| - puts "AHK_X11 is a Linux implementation for AutoHotkey classic version 1.0.24 (2004). Internal version: #{version}. Full up to date documentation can be found at https://phil294.github.io/AHK_X11/.\n\nPossible methods of invocation:\n\nahk_x11.AppImage \"path to script.ahk\"\nahk_x11.AppImage <<< $'MsgBox, 1\\nMsgBox, 2'\nahk_x11.AppImage --repl\nahk_x11.AppImage --windowspy\nahk_x11.AppImage --compile \"path to script.ahk\" \"optional: output executable file path\"\n\nAlternatively, just run the program without arguments to open the graphical installer. Once installed, you should be able to run and/or compile any .ahk file in your file manager by selecting it from the right click context menu." |
67 |
| - ::exit |
68 |
| - elsif ARGV[0] == "--repl" |
69 |
| - lines = ["#Persistent"] |
70 |
| - elsif ARGV[0] == "--windowspy" |
71 |
| - lines = {{ read_file("./src/window-spy.ahk").split("\n") }} |
72 |
| - elsif ARGV[0] == "--compile" |
73 |
| - build_error "Syntax: ahk_x11 --compile FILE_NAME [OUTPUT_FILENAME]" if ARGV.size < 2 |
74 |
| - Compiler.new.compile(filename_to_path(ARGV[1]), ARGV[2]? ? filename_to_path(ARGV[2]) : nil) |
75 |
| - ::exit |
76 |
| - else |
77 |
| - script_file = filename_to_path(ARGV[0]) |
78 |
| - begin |
79 |
| - ahk_str = File.read(script_file) |
80 |
| - rescue |
81 |
| - build_error "File '#{ARGV[0]}' could not be read." |
| 61 | +lines = Compiler.new.extract.try &.split('\n') |
| 62 | +if ! lines |
| 63 | + # Only needed for installer script, this can't (yet) really be part of ahk code. TODO: rm on exit |
| 64 | + File.write("/tmp/tmp_ahk_x11_logo.png", logo_blob) |
| 65 | + if ARGV[0]? |
| 66 | + if ARGV[0] == "-v" || ARGV[0] == "--version" |
| 67 | + puts "AHK_X11 version: #{version}\nTargets to partially implement Classic Windows AutoHotkey specification: v1.0.24 (2004). AutoHotkey is a scripting language." |
| 68 | + ::exit |
| 69 | + elsif ARGV[0] == "-h" || ARGV[0] == "--help" |
| 70 | + puts "AHK_X11 is a Linux implementation for AutoHotkey classic version 1.0.24 (2004). Internal version: #{version}. Full up to date documentation can be found at https://phil294.github.io/AHK_X11/.\n\nPossible methods of invocation:\n\nahk_x11.AppImage \"path to script.ahk\"\nahk_x11.AppImage <<< $'MsgBox, 1\\nMsgBox, 2'\nahk_x11.AppImage --repl\nahk_x11.AppImage --windowspy\nahk_x11.AppImage --compile \"path to script.ahk\" \"optional: output executable file path\"\n\nAlternatively, just run the program without arguments to open the graphical installer. Once installed, you should be able to run and/or compile any .ahk file in your file manager by selecting it from the right click context menu." |
| 71 | + ::exit |
| 72 | + elsif ARGV[0] == "--repl" |
| 73 | + lines = ["#Persistent"] |
| 74 | + elsif ARGV[0] == "--windowspy" |
| 75 | + lines = {{ read_file("./src/window-spy.ahk").split("\n") }} |
| 76 | + elsif ARGV[0] == "--compile" |
| 77 | + build_error "Syntax: ahk_x11 --compile FILE_NAME [OUTPUT_FILENAME]" if ARGV.size < 2 |
| 78 | + Compiler.new.compile(filename_to_path(ARGV[1]), ARGV[2]? ? filename_to_path(ARGV[2]) : nil) |
| 79 | + ::exit |
| 80 | + else |
| 81 | + script_file = filename_to_path(ARGV[0]) |
| 82 | + begin |
| 83 | + ahk_str = File.read(script_file) |
| 84 | + rescue |
| 85 | + build_error "File '#{ARGV[0]}' could not be read." |
| 86 | + end |
| 87 | + lines = ahk_str.split(/\r?\n/) |
82 | 88 | end
|
83 |
| - lines = ahk_str.split(/\r?\n/) |
84 |
| - end |
85 |
| -else |
86 |
| - stdin = Hacks.get_all_stdin_if_available |
87 |
| - if stdin |
88 |
| - lines = stdin.split('\n') |
89 | 89 | else
|
90 |
| - lines = Compiler.new.extract.try &.split('\n') |
91 |
| - abort "Argument missing." if ! lines |
92 |
| - # Only needed for installer script, this can't (yet) really be part of ahk code. TODO: rm on exit |
93 |
| - File.write("/tmp/tmp_ahk_x11_logo.png", logo_blob) |
| 90 | + stdin = Hacks.get_all_stdin_if_available |
| 91 | + if stdin |
| 92 | + lines = stdin.split('\n') |
| 93 | + else |
| 94 | + lines = {{ read_file("./src/installer.ahk").split("\n") }} |
| 95 | + end |
94 | 96 | end
|
95 | 97 | end
|
96 | 98 |
|
|
0 commit comments