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
|
# File 'lib/vkit/cli/commands/approval_watch_command.rb', line 12
def call(interval: DEFAULT_INTERVAL, format: "table", pretty: false, since: nil)
with_auth do
user = credential_store.user
org = user["organization_slug"]
since_time = parse_since(since)
seen = {}
if format == "table"
puts "ā³ Watching approval queue (Ctrl+C to stop)ā¦"
puts "Since: #{since_time.iso8601}" if since_time
puts
end
loop do
approvals =
authenticated_client.get(
"/api/v1/orgs/#{org}/approvals",
params: build_query(since_time)
)
approvals.each do |approval|
next if seen[approval["id"]]
emit(approval, format, pretty)
seen[approval["id"]] = true
end
sleep interval
end
end
rescue Interrupt
puts "\nš Watch stopped." if format == "table"
end
|