This repository has been archived by the owner on Feb 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
generate
executable file
·56 lines (50 loc) · 1.85 KB
/
generate
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
52
53
54
55
56
#!/usr/bin/env ruby
#
# Synopsis
# --------
#
# Generates template files for leaves, seasons, and other Autumn objects.
#
# Usage
# -----
#
#
# ```` sh
# script/generate <options> <template> <name>
# ````
#
# | | |
# |:-----------|:----------------------------------------------------------------------------------------------------------------------------------------|
# | `template` | The template to create. Valid templates are "leaf" and "season". |
# | `name` | The name to give the created template. For example, you can call `script/generate leaf Scorekeeper` to create a leaf named Scorekeeper. |
#
# Options
# -------
#
# | | |
# |:---------------|:------------------------------------------------------------------------------------------------------|
# | `--help`, `-h` | Displays this usage information. |
# | `--vcs`, `-c` | Add any created files or directories to the project's version control system (normally auto-detects). |
$: << Dir.getwd
require 'libs/script'
opts = GetoptLong.new(
['--help', '-h', GetoptLong::NO_ARGUMENT],
['--vcs', '-c', GetoptLong::NO_ARGUMENT]
)
script = Autumn::Script.new
begin
opts.each do |opt, _|
case opt
when '--help' then RDoc::usage
when '--vcs' then script.use_vcs
end
end
rescue GetoptLong::InvalidOption
RDoc::usage
exit 0
end
exit(0) unless script.parse_argv(ARGV)
case script.object
when 'leaf' then script.call_generator(:leaf)
when 'season' then script.call_generator(:season)
end