Skip to content

Commit

Permalink
fix GLI usage breaking faraday
Browse files Browse the repository at this point in the history
when using include at the top level, the module gets included in the Object class

Faraday::Middleware checks whether it responds to on_error, which then finds GLI's on_error, which has a different signature and meaning

this resolves that by wrapping the entire CLI in a class so that GLI::App is not included in Object

we also use GLI's built-in commands_from method to avoid having to reference every command file individually
  • Loading branch information
blowfishpro committed Nov 29, 2022
1 parent e6c1a3f commit 1ab48c2
Show file tree
Hide file tree
Showing 72 changed files with 2,702 additions and 2,375 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 2.0.1 (Next)

* Your contribution here.
* [#434](https://github.com/slack-ruby/slack-ruby-client/pull/434): Fix incompatibility with Faraday >= 2.7.0 and GLI usage in the `slack` script - [@blowfishpro](https://github.com/blowfishpro).

### 2.0.0 (2022/10/19)

Expand Down
69 changes: 0 additions & 69 deletions bin/commands.rb

This file was deleted.

26 changes: 16 additions & 10 deletions bin/commands/admin_analytics.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminAnalytics methods.'
command 'admin_analytics' do |g|
g.desc 'Retrieve analytics data for a given date, presented as a compressed JSON file'
g.long_desc %( Retrieve analytics data for a given date, presented as a compressed JSON file )
g.command 'getFile' do |c|
c.flag 'type', desc: 'The type of analytics to retrieve. The options are currently limited to member (for grid member analytics) and public_channel (for public channel analytics).'
c.flag 'date', desc: 'Date to retrieve the analytics data for, expressed as YYYY-MM-DD in UTC.'
c.flag 'metadata_only', desc: 'Retrieve metadata for the type of analytics indicated. Can be used only with type set to public_channel analytics. See detail below. Omit the date parameter when using this argument.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_analytics_getFile(options))
module Slack
module CLI
class App
desc 'AdminAnalytics methods.'
command 'admin_analytics' do |g|
g.desc 'Retrieve analytics data for a given date, presented as a compressed JSON file'
g.long_desc %( Retrieve analytics data for a given date, presented as a compressed JSON file )
g.command 'getFile' do |c|
c.flag 'type', desc: 'The type of analytics to retrieve. The options are currently limited to member (for grid member analytics) and public_channel (for public channel analytics).'
c.flag 'date', desc: 'Date to retrieve the analytics data for, expressed as YYYY-MM-DD in UTC.'
c.flag 'metadata_only', desc: 'Retrieve metadata for the type of analytics indicated. Can be used only with type set to public_channel analytics. See detail below. Omit the date parameter when using this argument.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_analytics_getFile(options))
end
end
end
end
end
end
90 changes: 48 additions & 42 deletions bin/commands/admin_apps.rb
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminApps methods.'
command 'admin_apps' do |g|
g.desc 'Approve an app for installation on a workspace.'
g.long_desc %( Approve an app for installation on a workspace. )
g.command 'approve' do |c|
c.flag 'app_id', desc: 'The id of the app to approve.'
c.flag 'enterprise_id', desc: 'The ID of the enterprise to approve the app on.'
c.flag 'request_id', desc: 'The id of the request to approve.'
c.flag 'team_id', desc: 'The ID of the workspace to approve the app on.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_approve(options))
end
end
module Slack
module CLI
class App
desc 'AdminApps methods.'
command 'admin_apps' do |g|
g.desc 'Approve an app for installation on a workspace.'
g.long_desc %( Approve an app for installation on a workspace. )
g.command 'approve' do |c|
c.flag 'app_id', desc: 'The id of the app to approve.'
c.flag 'enterprise_id', desc: 'The ID of the enterprise to approve the app on.'
c.flag 'request_id', desc: 'The id of the request to approve.'
c.flag 'team_id', desc: 'The ID of the workspace to approve the app on.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_approve(options))
end
end

g.desc 'Clear an app resolution'
g.long_desc %( Clear an app resolution )
g.command 'clearResolution' do |c|
c.flag 'app_id', desc: 'The id of the app whose resolution you want to clear/undo.'
c.flag 'enterprise_id', desc: 'The enterprise to clear the app resolution from.'
c.flag 'team_id', desc: 'The workspace to clear the app resolution from.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_clearResolution(options))
end
end
g.desc 'Clear an app resolution'
g.long_desc %( Clear an app resolution )
g.command 'clearResolution' do |c|
c.flag 'app_id', desc: 'The id of the app whose resolution you want to clear/undo.'
c.flag 'enterprise_id', desc: 'The enterprise to clear the app resolution from.'
c.flag 'team_id', desc: 'The workspace to clear the app resolution from.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_clearResolution(options))
end
end

g.desc 'Restrict an app for installation on a workspace.'
g.long_desc %( Restrict an app for installation on a workspace. )
g.command 'restrict' do |c|
c.flag 'app_id', desc: 'The id of the app to restrict.'
c.flag 'enterprise_id', desc: 'The ID of the enterprise to approve the app on.'
c.flag 'request_id', desc: 'The id of the request to restrict.'
c.flag 'team_id', desc: 'The ID of the workspace to approve the app on.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_restrict(options))
end
end
g.desc 'Restrict an app for installation on a workspace.'
g.long_desc %( Restrict an app for installation on a workspace. )
g.command 'restrict' do |c|
c.flag 'app_id', desc: 'The id of the app to restrict.'
c.flag 'enterprise_id', desc: 'The ID of the enterprise to approve the app on.'
c.flag 'request_id', desc: 'The id of the request to restrict.'
c.flag 'team_id', desc: 'The ID of the workspace to approve the app on.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_restrict(options))
end
end

g.desc 'Uninstall an app from one or many workspaces, or an entire enterprise organization.'
g.long_desc %( Uninstall an app from one or many workspaces, or an entire enterprise organization. )
g.command 'uninstall' do |c|
c.flag 'app_id', desc: 'The ID of the app to uninstall.'
c.flag 'enterprise_id', desc: 'The enterprise to completely uninstall the application from (across all workspaces). With an org-level token, this or team_ids is required.'
c.flag 'team_ids', desc: 'IDs of the teams to uninstall from (max 100). With an org-level token, this or enterprise_id is required.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_uninstall(options))
g.desc 'Uninstall an app from one or many workspaces, or an entire enterprise organization.'
g.long_desc %( Uninstall an app from one or many workspaces, or an entire enterprise organization. )
g.command 'uninstall' do |c|
c.flag 'app_id', desc: 'The ID of the app to uninstall.'
c.flag 'enterprise_id', desc: 'The enterprise to completely uninstall the application from (across all workspaces). With an org-level token, this or team_ids is required.'
c.flag 'team_ids', desc: 'IDs of the teams to uninstall from (max 100). With an org-level token, this or enterprise_id is required.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_uninstall(options))
end
end
end
end
end
end
28 changes: 17 additions & 11 deletions bin/commands/admin_apps_approved.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminAppsApproved methods.'
command 'admin_apps_approved' do |g|
g.desc 'List approved apps for an org or workspace.'
g.long_desc %( List approved apps for an org or workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'enterprise_id', desc: '.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_approved_list(options))
module Slack
module CLI
class App
desc 'AdminAppsApproved methods.'
command 'admin_apps_approved' do |g|
g.desc 'List approved apps for an org or workspace.'
g.long_desc %( List approved apps for an org or workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'enterprise_id', desc: '.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_approved_list(options))
end
end
end
end
end
end
48 changes: 27 additions & 21 deletions bin/commands/admin_apps_requests.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminAppsRequests methods.'
command 'admin_apps_requests' do |g|
g.desc 'Cancel approval request for team'
g.long_desc %( Cancel approval request for team )
g.command 'cancel' do |c|
c.flag 'request_id', desc: 'The id of the request to cancel.'
c.flag 'enterprise_id', desc: 'The ID of the enterprise where this request belongs.'
c.flag 'team_id', desc: 'The ID of the workspace where this request belongs.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_requests_cancel(options))
end
end
module Slack
module CLI
class App
desc 'AdminAppsRequests methods.'
command 'admin_apps_requests' do |g|
g.desc 'Cancel approval request for team'
g.long_desc %( Cancel approval request for team )
g.command 'cancel' do |c|
c.flag 'request_id', desc: 'The id of the request to cancel.'
c.flag 'enterprise_id', desc: 'The ID of the enterprise where this request belongs.'
c.flag 'team_id', desc: 'The ID of the workspace where this request belongs.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_requests_cancel(options))
end
end

g.desc 'List app requests for a team/workspace.'
g.long_desc %( List app requests for a team/workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'enterprise_id', desc: '.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_requests_list(options))
g.desc 'List app requests for a team/workspace.'
g.long_desc %( List app requests for a team/workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'enterprise_id', desc: '.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_requests_list(options))
end
end
end
end
end
end
28 changes: 17 additions & 11 deletions bin/commands/admin_apps_restricted.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminAppsRestricted methods.'
command 'admin_apps_restricted' do |g|
g.desc 'List restricted apps for an org or workspace.'
g.long_desc %( List restricted apps for an org or workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'enterprise_id', desc: '.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_apps_restricted_list(options))
module Slack
module CLI
class App
desc 'AdminAppsRestricted methods.'
command 'admin_apps_restricted' do |g|
g.desc 'List restricted apps for an org or workspace.'
g.long_desc %( List restricted apps for an org or workspace. )
g.command 'list' do |c|
c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
c.flag 'enterprise_id', desc: '.'
c.flag 'limit', desc: 'The maximum number of items to return. Must be between 1 - 1000 both inclusive.'
c.flag 'team_id', desc: '.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_apps_restricted_list(options))
end
end
end
end
end
end
38 changes: 22 additions & 16 deletions bin/commands/admin_audit_anomaly_allow.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

desc 'AdminAuditAnomalyAllow methods.'
command 'admin_audit_anomaly_allow' do |g|
g.desc 'API to allow enterprise grid admins to read the allow list of IP blocks and ASNs from the enterprise configuration.'
g.long_desc %( API to allow enterprise grid admins to read the allow list of IP blocks and ASNs from the enterprise configuration. )
g.command 'getItem' do |c|
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_audit_anomaly_allow_getItem(options))
end
end
module Slack
module CLI
class App
desc 'AdminAuditAnomalyAllow methods.'
command 'admin_audit_anomaly_allow' do |g|
g.desc 'API to allow enterprise grid admins to read the allow list of IP blocks and ASNs from the enterprise configuration.'
g.long_desc %( API to allow enterprise grid admins to read the allow list of IP blocks and ASNs from the enterprise configuration. )
g.command 'getItem' do |c|
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_audit_anomaly_allow_getItem(options))
end
end

g.desc 'API to allow enterprise grid admins to write/overwrite the allow list of IP blocks and ASNs from the enterprise configuration.'
g.long_desc %( API to allow enterprise grid admins to write/overwrite the allow list of IP blocks and ASNs from the enterprise configuration. )
g.command 'updateItem' do |c|
c.flag 'trusted_asns', desc: 'allow list of Autonomous System Numbers (ASN) in the enterprise grid configuarion.'
c.flag 'trusted_cidr', desc: 'allow list of IPv4 addressses using cidr notation in the enterprise grid configuarion.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.admin_audit_anomaly_allow_updateItem(options))
g.desc 'API to allow enterprise grid admins to write/overwrite the allow list of IP blocks and ASNs from the enterprise configuration.'
g.long_desc %( API to allow enterprise grid admins to write/overwrite the allow list of IP blocks and ASNs from the enterprise configuration. )
g.command 'updateItem' do |c|
c.flag 'trusted_asns', desc: 'allow list of Autonomous System Numbers (ASN) in the enterprise grid configuarion.'
c.flag 'trusted_cidr', desc: 'allow list of IPv4 addressses using cidr notation in the enterprise grid configuarion.'
c.action do |_global_options, options, _args|
puts JSON.dump(@client.admin_audit_anomaly_allow_updateItem(options))
end
end
end
end
end
end
Loading

0 comments on commit 1ab48c2

Please sign in to comment.