forked from ManageIQ/manageiq.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miq
executable file
·154 lines (129 loc) · 3.39 KB
/
miq
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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env ruby
require_relative "../lib/miq"
module Miq
#
# Reset repos back to clean state
#
class Reset < Thor
desc "all", "Reset all repos to clean state"
def all
invoke :guides
invoke :site
end
desc "guides", "Reset guides to clean state"
def guides
Guides.reset
end
desc "site", "Reset site repo to clean state"
def site
Site.reset
end
desc "reference", "Delete reference docs tmp directory"
def reference
RefDocs.reset
end
map "ref" => "reference"
end
#
# Update repos
#
class Update < Thor
desc "all", "Update guides and site from upstream; prime ref doc repo"
def all
invoke :guides
invoke :site
invoke :reference
end
desc "guides", "Reset and update guides repo"
def guides
say "Updating guides", :green
Guides.update
end
desc "site", "Reset and update site repo"
def site
say "Updating site", :green
Site.update
end
desc "reference", "Prime the reference docs staging directory"
def reference
say "Updating reference docs", :green
RefDocs.update
end
map "ref" => "reference"
end
#
# Build aspects of the site
#
class Build < Thor
desc "all", "Buildes guides, Jekyll site, and reference docs"
def all
say "Building all"
invoke :reference
invoke :guides
invoke :site
end
desc "guides", "Build guides"
def guides
say "Processing guides", :green
Guides.build
end
desc "site", "Build Jekyll site"
def site
say "Building Jekyll site", :green
Site.build options[:trace]
end
desc "reference", "Build Reference Docs"
def reference
say "Building reference docs", :green
RefDocs.build
LegacyRefDocs.build
end
map "ref" => "reference"
desc "menus", "Regenerate menu yaml files"
def menus
say "Rebuilding menu yaml files", :red
say "This will clobber existing files in tmp.", :red
answer = ask("Are you sure? Y/n")
if answer == "Y"
RefMenu.build
GuidesMenu.build
else
puts "Cancelled"
end
end
end
class Generate < Thor
desc "generate lwimiq", "Generate a LWIMIQ blog post"
long_desc <<-LONGDESC
Generates a new Last Week in ManageIQ blog post
skeleton. Includes all the links for PRs merged in the last week
in the various ManageIQ repositories.
With --current option, bin/miq generate lwimiq generates links
based on the current week instead of the last.
LONGDESC
option :current, :type => :boolean, :default => false
def lwimiq
say "Generating LWIMIQ post", :green
Lwimiq.generate(options)
end
end
#
# Top level command
#
class CLI < Thor
desc "reset <all|guides|site|reference>", "Reset repo(s) to clean state"
subcommand "reset", Reset
desc "update <all|guides|site|reference>", "Pull changes from origin repos"
subcommand "update", Update
desc "build <all|guides|site|reference>", "Build or process an aspect of the site"
option :trace, :type => :boolean, :default => false
subcommand "build", Build
desc "generate lwimiq YYYY-MM-DD", "Generate a new blog post"
subcommand "generate", Generate
desc "serve", "Does Jekyll serve with appropriate args"
def serve
Site.serve
end
end
end
Miq::CLI.start