diff options
author | Oran Agra <oran@redislabs.com> | 2022-04-27 16:32:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 16:32:17 +0300 |
commit | d375595d5e3ae2e5c29e6c00a2dc3d60578fd9fc (patch) | |
tree | c4d753d3ee0109e3513a879af8c5487e002d10a3 /utils/generate-command-help.rb | |
parent | fb4e0d400ff82117104bde5296c477ad95f8dd41 (diff) | |
parent | c1f3020631ea8640f2b6aa666a245dd76635a807 (diff) | |
download | redis-7.0.0.tar.gz |
Merge pull request #10652 from oranagra/redis-7.0.07.0.0
Redis 7.0.0
Diffstat (limited to 'utils/generate-command-help.rb')
-rwxr-xr-x | utils/generate-command-help.rb | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/utils/generate-command-help.rb b/utils/generate-command-help.rb index 482a3b9f8..3ef00b3b5 100755 --- a/utils/generate-command-help.rb +++ b/utils/generate-command-help.rb @@ -1,4 +1,9 @@ -#!/usr/bin/env ruby +#!/usr/bin/env ruby -w +# Usage: generate-command-help.r [path/to/commands.json] +# or: generate-commands-json.py | generate-command-help.rb - +# +# Defaults to downloading commands.json from the redis-doc repo if not provided +# or STDINed. GROUPS = [ "generic", @@ -66,16 +71,27 @@ def commands require "net/https" require "json" require "uri" - - url = URI.parse "https://raw.githubusercontent.com/redis/redis-doc/master/commands.json" - client = Net::HTTP.new url.host, url.port - client.use_ssl = true - response = client.get url.path - if response.is_a?(Net::HTTPSuccess) - @commands = JSON.parse(response.body) + if ARGV.length > 0 + if ARGV[0] == '-' + data = STDIN.read + elsif FileTest.exist? ARGV[0] + data = File.read(ARGV[0]) + else + raise Exception.new "File not found: #{ARGV[0]}" + end else - response.error! + url = URI.parse "https://raw.githubusercontent.com/redis/redis-doc/master/commands.json" + client = Net::HTTP.new url.host, url.port + client.use_ssl = true + response = client.get url.path + if !response.is_a?(Net::HTTPSuccess) + response.error! + return + else + data = response.body + end end + @commands = JSON.parse(data) end def generate_groups |