-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper
executable file
·51 lines (47 loc) · 1.57 KB
/
helper
1
2
3
4
5
6
7
8
9
10
11
12
13
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
#!/usr/bin/env ruby
# vim: set ft=rb
require 'pathname'
require_relative './lib/helpers.rb'
def usage
puts "Usage -> helper [command] [input-file]?"
puts
puts "Optional commands: "
usage_command("current", "c", "Show current problem")
usage_command("current-input", "ci", "Show current problem input file")
usage_command("current-example", "ce", "Show current problem example file")
usage_command("next", "n", "Show next problem")
usage_command("repl", "r", "Run repl with optional input file")
usage_command("input", "i", "Download input file")
usage_command("day", "d", "Create file for next problem")
usage_command("create", "cr", "Create file for next problem")
usage_command("example", "e", "Paste example to current problem file")
usage_command("help", "h", "Show this message")
end
def usage_command(name, short, message)
puts " - #{name.ljust(16)} #{"(#{short})".ljust(4)} #{message}"
end
case ARGV[0]
when "current", "c"
puts Problem.current.to_s
when "open", "code", "o"
Problem.current.code
when "current-input", "ci"
puts Problem.current.input_file
when "current-example", "ce"
puts Problem.current.example_file
when "next", "n"
puts Problem.next.to_s
when "repl", "r"
Repl.run(ARGV[1..])
when "input", "i"
Problem.current.download_input
when "day", "d", "create", "cr"
Problem.next.create_file
when "example", "e"
Problem.current.paste_example
when "help", "h", nil
usage
else
puts "Error: invalid argument #{ARGV.join(" ")}"
usage
end