Skip to content

Fixed the issue with knife -h command showing invalid subcommands - #88

Merged
jaymzh merged 2 commits into
mainfrom
CHEF-33284-knife-h-shows-invalid-subcommands
Apr 28, 2026
Merged

Fixed the issue with knife -h command showing invalid subcommands#88
jaymzh merged 2 commits into
mainfrom
CHEF-33284-knife-h-shows-invalid-subcommands

Conversation

@ashiqueps

Copy link
Copy Markdown
Contributor

Description

The knife -h command was showing invalid subcommands such as COMMAND COMMAND, SERVER COMMAND, RESOURCE COMMAND, etc., which were coming from the subclasses.

This PR updates the code to skip classes defined inside a subdirectory of the lib/chef/knife/ tree (e.g. lib/chef/knife/cloud/server/create_command.rb). By convention, real knife subcommands live directly at lib/chef/knife/.rb — the same flat pattern that GemGlobLoader uses when discovering commands. Abstract base classes from plugins like knife-cloud are nested in subdirs and are only loaded transitively; registering them causes spurious categories (e.g. ** SERVER COMMANDS **) to appear in 'knife --help'.

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@ashiqueps ashiqueps added the ai-assisted Work completed with AI assistance following Progress AI policies label Apr 16, 2026
@ashiqueps
ashiqueps requested review from a team and jaymzh as code owners April 16, 2026 12:07

@tpowell-progress tpowell-progress left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any tests or validation of this? I don't see example output from testing or anything.

Signed-off-by: Ashique Saidalavi <Ashique.saidalavi@progress.com>
Signed-off-by: Ashique Saidalavi <Ashique.saidalavi@progress.com>
@ashiqueps
ashiqueps force-pushed the CHEF-33284-knife-h-shows-invalid-subcommands branch from 355d5c0 to 2fbf355 Compare April 22, 2026 10:11
@ashiqueps

Copy link
Copy Markdown
Contributor Author

@tpowell-progress Added tests, please review.

@jaymzh
jaymzh merged commit 7637a9e into main Apr 28, 2026
45 checks passed
@jaymzh
jaymzh deleted the CHEF-33284-knife-h-shows-invalid-subcommands branch April 28, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Work completed with AI assistance following Progress AI policies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants