Skip to content

Commit

Permalink
fix: display sub-subcommands in help properly
Browse files Browse the repository at this point in the history
  • Loading branch information
drstrangelooker committed May 16, 2023
1 parent 3c37ea3 commit 889f2e4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/gzr/commands/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

# frozen_string_literal: true

require 'thor'
require_relative 'subcommandbase'

module Gzr
module Commands
class Permission < Thor
class Permission < SubCommandBase

require_relative 'permission/set'
register Gzr::Commands::Permission::Set, 'set', 'set [SUBCOMMAND]', 'Commands pertaining to permission sets'
Expand Down
8 changes: 7 additions & 1 deletion lib/gzr/commands/subcommandbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ class SubCommandBase < Thor
# Workaround so that help displays the right name
# base on this link
# https://github.com/erikhuda/thor/issues/261#issuecomment-69327685
# No longer needed
def self.banner(command, namespace = nil, subcommand = false)
"#{basename} #{subcommand_prefix} #{command.usage}"
end

def self.subcommand_prefix
self.namespace
end
end
end
end
18 changes: 9 additions & 9 deletions spec/integration/permission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
output = `gzr help permission`
expected_output = <<-OUT
Commands:
gzr permission help [COMMAND] # Describe subcommands or one specific subcommand
gzr permission ls # List all available permissions
gzr permission set [SUBCOMMAND] # Commands pertaining to permission sets
gzr permission tree # List all available permissions in a tree
gzr set cat PERMISSION_SET_ID # Output json information about a permission set to screen or file
gzr set help [COMMAND] # Describe subcommands or one specific subcommand
gzr set import FILE # Import a permission set from a file
gzr set ls # List the permission sets in this server.
gzr set rm PERMISSION_SET_ID # Delete the permission_set given by PERMISSION_SET_ID
gzr permission help [COMMAND] # Describe subcommands or one specific subcommand
gzr permission ls # List all available permissions
gzr permission set [SUBCOMMAND] # Commands pertaining to permission sets
gzr permission set cat PERMISSION_SET_ID # Output json information about a permission set to screen or file
gzr permission set help [COMMAND] # Describe subcommands or one specific subcommand
gzr permission set import FILE # Import a permission set from a file
gzr permission set ls # List the permission sets in this server.
gzr permission set rm PERMISSION_SET_ID # Delete the permission_set given by PERMISSION_SET_ID
gzr permission tree # List all available permissions in a tree
OUT

Expand Down

0 comments on commit 889f2e4

Please sign in to comment.