wassup 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.gitignore +4 -0
- data/Gemfile.lock +19 -1
- data/README.md +45 -5
- data/bin/wassup +6 -1
- data/docs/.gitignore +20 -0
- data/docs/README.md +41 -0
- data/docs/babel.config.js +3 -0
- data/docs/blog/2021-12-09-welcome/index.md +8 -0
- data/docs/blog/authors.yml +5 -0
- data/docs/docs/Supfile-basics/_category_.json +4 -0
- data/docs/docs/Supfile-basics/understanding-the-supfile.md +50 -0
- data/docs/docs/intro.md +54 -0
- data/docs/docusaurus.config.js +110 -0
- data/docs/package-lock.json +21196 -0
- data/docs/package.json +43 -0
- data/docs/sidebars.js +31 -0
- data/docs/src/components/HomepageFeatures.module.css +10 -0
- data/docs/src/components/HomepageFeatures.tsx +60 -0
- data/docs/src/css/custom.css +28 -0
- data/docs/src/pages/index.module.css +36 -0
- data/docs/src/pages/index.tsx +39 -0
- data/docs/src/pages/markdown-page.md +7 -0
- data/docs/static/.nojekyll +0 -0
- data/docs/static/img/demo-supfile.png +0 -0
- data/docs/static/img/favicon.ico +0 -0
- data/docs/static/img/logo.svg +27 -0
- data/docs/static/img/tutorial/docsVersionDropdown.png +0 -0
- data/docs/static/img/tutorial/localeDropdown.png +0 -0
- data/docs/static/img/tutorial-intro-starter-screenshot.png +0 -0
- data/docs/static/img/undraw_docusaurus_mountain.svg +170 -0
- data/docs/static/img/undraw_docusaurus_react.svg +169 -0
- data/docs/static/img/undraw_docusaurus_tree.svg +1 -0
- data/docs/static/img/wassup-long.png +0 -0
- data/docs/static/img/wassup-screenshot.png +0 -0
- data/docs/static/img/wassup.png +0 -0
- data/docs/static/video/wassup-demo.mov +0 -0
- data/docs/tsconfig.json +7 -0
- data/examples/basic/Supfile +195 -0
- data/examples/debug/Supfile +131 -0
- data/examples/josh-fastlane/README.md +14 -0
- data/examples/josh-fastlane/Supfile +70 -109
- data/examples/josh-fastlane/demo.png +0 -0
- data/examples/simple/Supfile +17 -0
- data/examples/starter/Supfile +44 -0
- data/lib/wassup/app.rb +178 -10
- data/lib/wassup/color.rb +81 -0
- data/lib/wassup/helpers/circleci.rb +75 -0
- data/lib/wassup/helpers/github.rb +137 -0
- data/lib/wassup/helpers/netlify.rb +70 -0
- data/lib/wassup/helpers/shortcut.rb +114 -0
- data/lib/wassup/pane.rb +298 -90
- data/lib/wassup/pane_builder.rb +74 -3
- data/lib/wassup/version.rb +1 -1
- data/lib/wassup.rb +6 -0
- data/wassup.gemspec +1 -0
- metadata +61 -2
|
@@ -3,6 +3,8 @@ require 'rest-client'
|
|
|
3
3
|
require 'json'
|
|
4
4
|
require 'colorize'
|
|
5
5
|
|
|
6
|
+
require 'curses'
|
|
7
|
+
|
|
6
8
|
fastlane_community_prs = []
|
|
7
9
|
fastlane_prs = []
|
|
8
10
|
|
|
@@ -18,9 +20,13 @@ add_pane do |pane|
|
|
|
18
20
|
pane.highlight = false
|
|
19
21
|
|
|
20
22
|
pane.title = "Stats: fastlane-community"
|
|
23
|
+
pane.description = [
|
|
24
|
+
"Highlevel stats from fastlane-community about PR count"
|
|
25
|
+
]
|
|
21
26
|
|
|
22
|
-
pane.interval =
|
|
23
|
-
pane.
|
|
27
|
+
pane.interval = 2
|
|
28
|
+
pane.show_refresh = false
|
|
29
|
+
pane.content do |builder|
|
|
24
30
|
days_1 = 0
|
|
25
31
|
days_7 = 0
|
|
26
32
|
days_30 = 0
|
|
@@ -39,13 +45,11 @@ add_pane do |pane|
|
|
|
39
45
|
days_365 +=1 if days <= 365
|
|
40
46
|
end
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"Opened 365 days: #{days_365}"
|
|
48
|
-
]
|
|
48
|
+
builder.add_row("Opened today: #{days_1}")
|
|
49
|
+
builder.add_row("Opened 7 days: #{days_7}")
|
|
50
|
+
builder.add_row("Opened 30 days: #{days_30}")
|
|
51
|
+
builder.add_row("Opened 60 days: #{days_60}")
|
|
52
|
+
builder.add_row("Opened 365 days: #{days_365}")
|
|
49
53
|
end
|
|
50
54
|
end
|
|
51
55
|
|
|
@@ -61,9 +65,13 @@ add_pane do |pane|
|
|
|
61
65
|
pane.highlight = false
|
|
62
66
|
|
|
63
67
|
pane.title = "Stats: fastlane/fastlane"
|
|
68
|
+
pane.description = [
|
|
69
|
+
"Highlevel stats from fastlane/fastlane about PR count"
|
|
70
|
+
]
|
|
64
71
|
|
|
65
|
-
pane.interval =
|
|
66
|
-
pane.
|
|
72
|
+
pane.interval = 2
|
|
73
|
+
pane.show_refresh = false
|
|
74
|
+
pane.content do |builder|
|
|
67
75
|
days_1 = 0
|
|
68
76
|
days_7 = 0
|
|
69
77
|
days_30 = 0
|
|
@@ -84,14 +92,12 @@ add_pane do |pane|
|
|
|
84
92
|
days_60_plus +=1 if days > 60
|
|
85
93
|
end
|
|
86
94
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"More than 60 days: #{days_60_plus}",
|
|
94
|
-
]
|
|
95
|
+
builder.add_row("Opened today: #{days_1}")
|
|
96
|
+
builder.add_row("Opened 7 days: #{days_7}")
|
|
97
|
+
builder.add_row("Opened 30 days: #{days_30}")
|
|
98
|
+
builder.add_row("Opened 45 days: #{days_45}")
|
|
99
|
+
builder.add_row("Opened 60 days: #{days_60}")
|
|
100
|
+
builder.add_row("More than 60 days: #{days_60_plus}")
|
|
95
101
|
end
|
|
96
102
|
end
|
|
97
103
|
|
|
@@ -107,45 +113,35 @@ add_pane do |pane|
|
|
|
107
113
|
pane.highlight = true
|
|
108
114
|
|
|
109
115
|
pane.title = "Circle CI - fastlane/fastlane"
|
|
116
|
+
pane.description = [
|
|
117
|
+
"Shows workflows from last 14 days"
|
|
118
|
+
]
|
|
110
119
|
|
|
111
120
|
pane.interval = 60 * 5
|
|
112
|
-
pane.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
json["items"].select do |item|
|
|
120
|
-
date = Time.parse(item["updated_at"])
|
|
121
|
-
days = (Time.now - date).to_i / (24 * 60 * 60)
|
|
122
|
-
days < 14
|
|
123
|
-
end.map do |item|
|
|
124
|
-
id = item["id"]
|
|
125
|
-
number = item["number"]
|
|
126
|
-
message = item["vcs"]["commit"]["subject"]
|
|
127
|
-
login = item["trigger"]["actor"]["login"]
|
|
128
|
-
|
|
129
|
-
resp = RestClient::Request.execute(
|
|
130
|
-
method: :get,
|
|
131
|
-
url: "https://circleci.com/api/v2/pipeline/#{id}/workflow",
|
|
132
|
-
headers: { "Circle-Token": ENV["WASSUP_CIRCLE_CI_API_TOKEN"] }
|
|
133
|
-
)
|
|
134
|
-
json = JSON.parse(resp)
|
|
135
|
-
workflow = json["items"].first
|
|
136
|
-
status = workflow["status"]
|
|
137
|
-
|
|
138
|
-
["#{number} (#{status}) by #{login} - #{message}", workflow]
|
|
121
|
+
pane.show_refresh = true
|
|
122
|
+
|
|
123
|
+
pane.content do |builder|
|
|
124
|
+
workflows = Helpers::CircleCI.workflows(vcs: 'github', org: 'fastlane', repo: 'fastlane', limit_days: 14)
|
|
125
|
+
workflows.each do |workflow|
|
|
126
|
+
display = Helpers::CircleCI::Formatter.workflow(workflow)
|
|
127
|
+
builder.add_row(display, workflow)
|
|
139
128
|
end
|
|
140
129
|
end
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
|
|
131
|
+
pane.selection('enter', 'Opens up CirceCI workflow') do |workflow|
|
|
132
|
+
slug = workflow["project_slug"]
|
|
133
|
+
pipeline_number = workflow["pipeline_number"]
|
|
134
|
+
workflow_id = workflow["id"]
|
|
145
135
|
|
|
146
136
|
url = "https://app.circleci.com/pipelines/#{slug}/#{pipeline_number}/workflows/#{workflow_id}"
|
|
147
137
|
`open #{url}`
|
|
148
138
|
end
|
|
139
|
+
|
|
140
|
+
pane.selection('o', 'Opens up version control review URL') do |workflow|
|
|
141
|
+
pipeline = workflow["pipeline"]
|
|
142
|
+
url = pipeline["vcs"]["review_url"]
|
|
143
|
+
`open #{url}`
|
|
144
|
+
end
|
|
149
145
|
end
|
|
150
146
|
|
|
151
147
|
#
|
|
@@ -160,52 +156,26 @@ add_pane do |pane|
|
|
|
160
156
|
pane.highlight = true
|
|
161
157
|
|
|
162
158
|
pane.title = "Open PRs - fastlane-community"
|
|
159
|
+
pane.description = [
|
|
160
|
+
"Open PRs from all the fastlane-community repos"
|
|
161
|
+
]
|
|
163
162
|
|
|
164
163
|
pane.interval = 60 * 5
|
|
165
|
-
pane.
|
|
164
|
+
pane.show_refresh = true
|
|
165
|
+
pane.content do |builder|
|
|
166
166
|
fastlane_community_prs = []
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
name = repo["name"]
|
|
177
|
-
full_name = repo["full_name"]
|
|
178
|
-
|
|
179
|
-
resp = RestClient::Request.execute(
|
|
180
|
-
method: :get,
|
|
181
|
-
url: "https://api.github.com/repos/#{full_name}/pulls",
|
|
182
|
-
user: ENV["WASSUP_GITHUB_USERNAME"],
|
|
183
|
-
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
|
|
184
|
-
)
|
|
185
|
-
json = JSON.parse(resp)
|
|
186
|
-
prs = json.map do |pr|
|
|
187
|
-
fastlane_community_prs << pr
|
|
188
|
-
|
|
189
|
-
number = pr["number"]
|
|
190
|
-
title = pr["title"]
|
|
191
|
-
created_at = pr["created_at"]
|
|
192
|
-
|
|
193
|
-
number_formatted = '%5.5s' % "##{number}"
|
|
194
|
-
|
|
195
|
-
date = Time.parse(created_at)
|
|
196
|
-
days = (Time.now - date).to_i / (24 * 60 * 60)
|
|
197
|
-
days_formatted = '%3.3s' % days.to_s
|
|
198
|
-
|
|
199
|
-
["#{number_formatted} #{days_formatted}d ago #{title}",pr]
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
{
|
|
203
|
-
title: name,
|
|
204
|
-
content: prs
|
|
205
|
-
}
|
|
168
|
+
prs = Wassup::Helpers::GitHub.pull_requests(org: 'fastlane-community')
|
|
169
|
+
prs.each do |pr|
|
|
170
|
+
fastlane_community_prs << pr
|
|
171
|
+
|
|
172
|
+
repo_name = pr["base"]["repo"]["name"]
|
|
173
|
+
|
|
174
|
+
display = Helpers::GitHub::Formatter.pr(pr)
|
|
175
|
+
builder.add_row(display, pr, page: repo_name)
|
|
206
176
|
end
|
|
207
177
|
end
|
|
208
|
-
pane.selection do |data|
|
|
178
|
+
pane.selection('enter', 'Open PR in web browser') do |data|
|
|
209
179
|
url = data["html_url"]
|
|
210
180
|
`open #{url}`
|
|
211
181
|
end
|
|
@@ -224,33 +194,24 @@ add_pane do |pane|
|
|
|
224
194
|
pane.highlight = true
|
|
225
195
|
|
|
226
196
|
pane.title = "Open PRs - fastlane/fastlane"
|
|
197
|
+
pane.description = [
|
|
198
|
+
"Open PRs from all the fastlane/fastlane repo"
|
|
199
|
+
]
|
|
227
200
|
|
|
228
201
|
pane.interval = 60 * 5
|
|
229
|
-
pane.
|
|
202
|
+
pane.show_refresh = true
|
|
203
|
+
pane.content do |builder|
|
|
230
204
|
fastlane_prs = []
|
|
231
205
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
url: "https://api.github.com/repos/fastlane/fastlane/pulls?per_page=100",
|
|
235
|
-
user: ENV["WASSUP_GITHUB_USERNAME"],
|
|
236
|
-
password: ENV["WASSUP_GITHUB_ACCESS_TOKEN"]
|
|
237
|
-
)
|
|
238
|
-
json = JSON.parse(resp)
|
|
239
|
-
json.map do |pr|
|
|
206
|
+
prs = Wassup::Helpers::GitHub.pull_requests(org: 'fastlane', repo: 'fastlane')
|
|
207
|
+
prs.each do |pr|
|
|
240
208
|
fastlane_prs << pr
|
|
241
209
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
created_at = pr["created_at"]
|
|
245
|
-
|
|
246
|
-
date = Time.parse(created_at)
|
|
247
|
-
days = (Time.now - date).to_i / (24 * 60 * 60)
|
|
248
|
-
days_formatted = '%3.3s' % days.to_s
|
|
249
|
-
|
|
250
|
-
["##{number} #{days_formatted}d ago #{title}",pr]
|
|
210
|
+
display = Helpers::GitHub::Formatter.pr(pr)
|
|
211
|
+
builder.add_row(display, pr)
|
|
251
212
|
end
|
|
252
213
|
end
|
|
253
|
-
pane.selection do |data|
|
|
214
|
+
pane.selection('enter', 'Open PR in browser') do |data|
|
|
254
215
|
url = data["html_url"]
|
|
255
216
|
`open #{url}`
|
|
256
217
|
end
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
add_pane do |pane|
|
|
2
|
+
pane.height = 0.25
|
|
3
|
+
pane.width = 0.25
|
|
4
|
+
pane.top = 0
|
|
5
|
+
pane.left = 0
|
|
6
|
+
|
|
7
|
+
pane.highlight = false
|
|
8
|
+
pane.title = "The Title"
|
|
9
|
+
|
|
10
|
+
pane.interval = 1
|
|
11
|
+
pane.content do |content|
|
|
12
|
+
date = `date`
|
|
13
|
+
content.add_row(date)
|
|
14
|
+
content.add_row(date, page: "page 2")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
add_pane do |pane|
|
|
2
|
+
pane.height = 0.5
|
|
3
|
+
pane.width = 0.4
|
|
4
|
+
pane.top = 0
|
|
5
|
+
pane.left = 0
|
|
6
|
+
|
|
7
|
+
pane.highlight = false
|
|
8
|
+
pane.title = "Current Time"
|
|
9
|
+
|
|
10
|
+
pane.interval = 1
|
|
11
|
+
pane.content do |content|
|
|
12
|
+
date = `date`
|
|
13
|
+
|
|
14
|
+
content.add_row(date)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
add_pane do |pane|
|
|
19
|
+
pane.height = 0.5
|
|
20
|
+
pane.width = 0.6
|
|
21
|
+
pane.top = 0
|
|
22
|
+
pane.left = 0.4
|
|
23
|
+
|
|
24
|
+
pane.highlight = false
|
|
25
|
+
pane.title = "Open PRs - fastlane/fastlane"
|
|
26
|
+
|
|
27
|
+
pane.interval = 60 * 5
|
|
28
|
+
pane.content do |content|
|
|
29
|
+
require 'uri'
|
|
30
|
+
require 'net/http'
|
|
31
|
+
require 'json'
|
|
32
|
+
|
|
33
|
+
uri = URI('https://api.github.com/repos/fastlane/fastlane/pulls')
|
|
34
|
+
res = Net::HTTP.get_response(uri)
|
|
35
|
+
|
|
36
|
+
JSON.parse(res.body).each do |pr|
|
|
37
|
+
display = "[fg=cyan]##{pr['number']} - [fg=white]#{pr['title']}"
|
|
38
|
+
content.add_row(display)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
pane.selection do |pr|
|
|
42
|
+
`open #{pr['html_url']}`
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/wassup/app.rb
CHANGED
|
@@ -10,14 +10,54 @@ module Wassup
|
|
|
10
10
|
|
|
11
11
|
Curses.stdscr.scrollok true
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
Wassup::Color.init
|
|
14
|
+
|
|
15
|
+
# Determines the colors in the 'attron' below
|
|
16
|
+
|
|
17
|
+
#Curses.init_pair(Curses::COLOR_BLUE,Curses::COLOR_BLUE,Curses::COLOR_BLACK)
|
|
18
|
+
#Curses.init_pair(Curses::COLOR_RED,Curses::COLOR_RED,Curses::COLOR_BLACK)
|
|
17
19
|
|
|
18
20
|
app = App.new(path: path)
|
|
19
21
|
end
|
|
20
22
|
|
|
23
|
+
def self.debug(path:)
|
|
24
|
+
app = App.new(path: path, debug: true)
|
|
25
|
+
|
|
26
|
+
app.panes.each do |k, pane|
|
|
27
|
+
puts "#{k} - #{pane.title}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
puts ""
|
|
31
|
+
puts "Choose a pane to run:"
|
|
32
|
+
|
|
33
|
+
selection = $stdin.gets.chomp.to_s
|
|
34
|
+
|
|
35
|
+
pane = app.panes[selection]
|
|
36
|
+
if pane.nil?
|
|
37
|
+
puts "That was not a valid option"
|
|
38
|
+
else
|
|
39
|
+
puts "Going to run: \"#{pane.title}\""
|
|
40
|
+
|
|
41
|
+
builder = Wassup::PaneBuilder::ContentBuilder.new(pane.contents)
|
|
42
|
+
pane.content_block.call(builder)
|
|
43
|
+
|
|
44
|
+
builder.contents.each_with_index do |content|
|
|
45
|
+
puts "#########################"
|
|
46
|
+
puts "# #{content.title || (idx == 0 ? "Default" : "<No Title>")}"
|
|
47
|
+
puts "#########################"
|
|
48
|
+
|
|
49
|
+
content.data.each do |data|
|
|
50
|
+
puts data.display
|
|
51
|
+
.split(/\[.*?\]/).join('') # Removes colors but make this an option probably
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
puts ""
|
|
55
|
+
puts ""
|
|
56
|
+
puts ""
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
21
61
|
def add_pane
|
|
22
62
|
pane_builder = Wassup::PaneBuilder.new
|
|
23
63
|
yield(pane_builder)
|
|
@@ -29,22 +69,62 @@ module Wassup
|
|
|
29
69
|
pane_builder.top,
|
|
30
70
|
pane_builder.left,
|
|
31
71
|
title: pane_builder.title,
|
|
72
|
+
description: pane_builder.description,
|
|
32
73
|
highlight: pane_builder.highlight,
|
|
33
74
|
focus_number: number,
|
|
34
75
|
interval: pane_builder.interval,
|
|
76
|
+
show_refresh: pane_builder.show_refresh,
|
|
35
77
|
content_block: pane_builder.content_block,
|
|
36
|
-
|
|
78
|
+
selection_blocks: pane_builder.selection_blocks,
|
|
79
|
+
selection_blocks_description: pane_builder.selection_blocks_description,
|
|
80
|
+
debug: debug
|
|
37
81
|
)
|
|
38
82
|
pane.focus_handler = @focus_handler
|
|
39
83
|
@panes[number.to_s] = pane
|
|
40
84
|
end
|
|
41
85
|
|
|
42
|
-
|
|
86
|
+
attr_accessor :panes
|
|
87
|
+
attr_accessor :debug
|
|
88
|
+
|
|
89
|
+
def initialize(path:, debug: false)
|
|
43
90
|
@hidden_pane = nil
|
|
91
|
+
@help_pane = nil
|
|
44
92
|
@focused_pane = nil
|
|
45
93
|
@panes = {}
|
|
94
|
+
@debug = debug
|
|
46
95
|
|
|
96
|
+
if debug
|
|
97
|
+
self.start_debug(path)
|
|
98
|
+
else
|
|
99
|
+
self.start_curses(path)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def start_debug(path)
|
|
104
|
+
begin
|
|
105
|
+
eval(File.new(path).read)
|
|
106
|
+
rescue => err
|
|
107
|
+
puts err
|
|
108
|
+
puts err.backtrace
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def start_curses(path)
|
|
113
|
+
@redraw_panes = false
|
|
114
|
+
|
|
115
|
+
# TODO: this could maybe get replaced with selection_blocks now
|
|
47
116
|
@focus_handler = Proc.new do |input|
|
|
117
|
+
is_help_open = !@help_pane.nil?
|
|
118
|
+
|
|
119
|
+
if input == "q"
|
|
120
|
+
exit
|
|
121
|
+
elsif input == "?"
|
|
122
|
+
toggle_help
|
|
123
|
+
next true
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
next true if is_help_open
|
|
127
|
+
|
|
48
128
|
if (pane = @panes[input.to_s])
|
|
49
129
|
@focused_pane.focused = false
|
|
50
130
|
|
|
@@ -66,8 +146,7 @@ module Wassup
|
|
|
66
146
|
end
|
|
67
147
|
|
|
68
148
|
begin
|
|
69
|
-
|
|
70
|
-
@hidden_pane = Pane.new(0, 0, 0, 0, highlight: false, focus_number: 0, interval: nil, content_block: nil, selection_block: nil)
|
|
149
|
+
@hidden_pane = Pane.new(0, 0, 0, 0, highlight: false, focus_number: 0, interval: nil, show_refresh: false, content_block: nil, selection_blocks: nil, selection_blocks_description: nil)
|
|
71
150
|
@hidden_pane.focus_handler = @focus_handler
|
|
72
151
|
@focused_pane = @hidden_pane
|
|
73
152
|
|
|
@@ -75,13 +154,102 @@ module Wassup
|
|
|
75
154
|
|
|
76
155
|
loop do
|
|
77
156
|
@focused_pane.handle_keyboard
|
|
78
|
-
|
|
79
|
-
|
|
157
|
+
|
|
158
|
+
if @redraw_panes
|
|
159
|
+
Curses.clear
|
|
160
|
+
Curses.refresh
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# This isn't ideal to now refresh other panes when help is open
|
|
164
|
+
# But it prevents things from getting drawn where the help is showing
|
|
165
|
+
if @help_pane.nil?
|
|
166
|
+
@panes.each do |id, pane|
|
|
167
|
+
pane.redraw() if @redraw_panes
|
|
168
|
+
pane.refresh()
|
|
169
|
+
end
|
|
170
|
+
@redraw_panes = false
|
|
171
|
+
else
|
|
172
|
+
@help_pane.refresh()
|
|
80
173
|
end
|
|
81
174
|
end
|
|
82
175
|
ensure
|
|
83
176
|
Curses.close_screen
|
|
84
177
|
end
|
|
85
178
|
end
|
|
179
|
+
|
|
180
|
+
def row_help
|
|
181
|
+
{
|
|
182
|
+
"j" => "moves row highlight down",
|
|
183
|
+
"k" => "moves row highlight up",
|
|
184
|
+
"enter" => "perform selection on highlighted row"
|
|
185
|
+
}
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def page_help
|
|
189
|
+
{
|
|
190
|
+
"h" => "previous page in pane",
|
|
191
|
+
"l" => "next page in pane"
|
|
192
|
+
}
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def toggle_help
|
|
196
|
+
if @help_pane.nil?
|
|
197
|
+
if @focused_pane == @hidden_pane
|
|
198
|
+
content_block = Proc.new do |content|
|
|
199
|
+
items = [
|
|
200
|
+
"Welcome to Wassup!",
|
|
201
|
+
"",
|
|
202
|
+
"Press any number key to focus a pane",
|
|
203
|
+
"",
|
|
204
|
+
row_help.map { |k,v| "#{k} - #{v}"},
|
|
205
|
+
"",
|
|
206
|
+
page_help.map { |k,v| "#{k} - #{v}"},
|
|
207
|
+
"",
|
|
208
|
+
"? - opens help for focused pane"
|
|
209
|
+
].flatten
|
|
210
|
+
|
|
211
|
+
items.each do |item|
|
|
212
|
+
content.add_row(item)
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
else
|
|
216
|
+
content_block = Proc.new do |content|
|
|
217
|
+
hash = {}
|
|
218
|
+
|
|
219
|
+
hash = hash.merge(row_help)
|
|
220
|
+
hash = hash.merge(@focused_pane.selection_blocks_description)
|
|
221
|
+
|
|
222
|
+
row_help.map { |k,v| "#{k} - #{v}"}
|
|
223
|
+
|
|
224
|
+
copy_error = @focused_pane.caught_error.nil? ? [] : [
|
|
225
|
+
"c - copy stacktrace to clipboard",
|
|
226
|
+
""
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
items = [
|
|
230
|
+
@focused_pane.description,
|
|
231
|
+
"",
|
|
232
|
+
hash.map do |k,v|
|
|
233
|
+
"#{k} - #{v}"
|
|
234
|
+
end,
|
|
235
|
+
"",
|
|
236
|
+
copy_error,
|
|
237
|
+
page_help.map { |k,v| "#{k} - #{v}"},
|
|
238
|
+
].flatten.compact
|
|
239
|
+
|
|
240
|
+
items.each do |item|
|
|
241
|
+
content.add_row(item)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Maybe find a way to add some a second border or an clear border to add more space to show its floating
|
|
247
|
+
@help_pane = Pane.new(0.5, 0.5, 0.25, 0.25, title: "Help", highlight: false, focus_number: nil, interval: 100, show_refresh: false, content_block: content_block, selection_blocks: nil, selection_blocks_description: nil)
|
|
248
|
+
else
|
|
249
|
+
@help_pane.close
|
|
250
|
+
@help_pane = nil
|
|
251
|
+
@redraw_panes = true
|
|
252
|
+
end
|
|
253
|
+
end
|
|
86
254
|
end
|
|
87
255
|
end
|
data/lib/wassup/color.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require 'curses'
|
|
2
|
+
|
|
3
|
+
module Wassup
|
|
4
|
+
class Color
|
|
5
|
+
attr_accessor :color_pair
|
|
6
|
+
|
|
7
|
+
module Pair
|
|
8
|
+
BLACK = 0
|
|
9
|
+
BLUE = 1
|
|
10
|
+
CYAN = 2
|
|
11
|
+
GREEN = 3
|
|
12
|
+
MAGENTA = 4
|
|
13
|
+
RED = 5
|
|
14
|
+
WHITE = 15
|
|
15
|
+
YELLOW = 7
|
|
16
|
+
|
|
17
|
+
NORMAL = 20
|
|
18
|
+
HIGHLIGHT = 21
|
|
19
|
+
|
|
20
|
+
GRAY = 22
|
|
21
|
+
|
|
22
|
+
BORDER = 20
|
|
23
|
+
BORDER_FOCUS = 7
|
|
24
|
+
|
|
25
|
+
TITLE = 20
|
|
26
|
+
TITLE_FOCUS = 20
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.init
|
|
30
|
+
Curses.use_default_colors()
|
|
31
|
+
|
|
32
|
+
Curses.init_pair(Pair::NORMAL, Pair::WHITE, 0) #white foreground, black background
|
|
33
|
+
Curses.init_pair(Pair::HIGHLIGHT, 0, Pair::WHITE) # black foreground, white background
|
|
34
|
+
|
|
35
|
+
# Curses.init_pair(Pair::BORDER, Pair::WHITE, 0) #white foreground, black background
|
|
36
|
+
# Curses.init_pair(Pair::BORDER_FOCUS, Pair::MAGENTA, 0) #white foreground, black background
|
|
37
|
+
#
|
|
38
|
+
# Curses.init_pair(Pair::TITLE, Pair::WHITE, 0) #white foreground, black background
|
|
39
|
+
# Curses.init_pair(Pair::TITLE_FOCUS, Pair::WHITE, 0) #white foreground, black background
|
|
40
|
+
|
|
41
|
+
Curses.init_pair(Pair::BLACK, Curses::COLOR_BLACK, 0)
|
|
42
|
+
Curses.init_pair(Pair::BLUE, Curses::COLOR_BLUE, 0)
|
|
43
|
+
Curses.init_pair(Pair::CYAN, Curses::COLOR_CYAN, 0)
|
|
44
|
+
Curses.init_pair(Pair::GREEN, Curses::COLOR_GREEN, 0)
|
|
45
|
+
Curses.init_pair(Pair::MAGENTA, Curses::COLOR_MAGENTA, 0)
|
|
46
|
+
Curses.init_pair(Pair::RED, Curses::COLOR_RED, 0)
|
|
47
|
+
Curses.init_pair(Pair::WHITE, Pair::WHITE, 0)
|
|
48
|
+
Curses.init_pair(Pair::YELLOW, Curses::COLOR_YELLOW, 0)
|
|
49
|
+
Curses.init_pair(Pair::GRAY, Curses::COLOR_WHITE, 0)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def initialize(string_name)
|
|
53
|
+
@color_pair = case string_name
|
|
54
|
+
when "black"
|
|
55
|
+
Pair::BLACK
|
|
56
|
+
when "blue"
|
|
57
|
+
Pair::BLUE
|
|
58
|
+
when "cyan"
|
|
59
|
+
Pair::CYAN
|
|
60
|
+
when "green"
|
|
61
|
+
Pair::GREEN
|
|
62
|
+
when "magenta"
|
|
63
|
+
Pair::MAGENTA
|
|
64
|
+
when "red"
|
|
65
|
+
Pair::RED
|
|
66
|
+
when "white"
|
|
67
|
+
Pair::WHITE
|
|
68
|
+
when "yellow"
|
|
69
|
+
Pair::YELLOW
|
|
70
|
+
when "gray"
|
|
71
|
+
Pair::GRAY
|
|
72
|
+
else
|
|
73
|
+
if string_name.to_i.to_s == string_name
|
|
74
|
+
string_name.to_i
|
|
75
|
+
else
|
|
76
|
+
Pair::WHITE
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|