Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #20804 - Support for deprecating commands #251

Merged
merged 1 commit into from
Oct 18, 2017

Conversation

rabajaj0509
Copy link
Member

No description provided.

@rabajaj0509
Copy link
Member Author

@tstrachota hey, i have tried doing this, it is not working as expected, can you give some input to it ?

@tstrachota
Copy link
Member

@rahulbajaj0509 what exactly does not work for you? I gave it a try and it seems to work:

    HammerCLI::MainCommand.lazy_subcommand('architecture', _("Manipulate architectures."),
      'HammerCLIForeman::Architecture', 'hammer_cli_foreman/architecture',
      true
    )

...and the architecture is gone from hammer -h.

We need to extend also subcommand though. Not all commands are loaded lazily in hammer.

@rabajaj0509
Copy link
Member Author

@tstrachota actually the lazy_subcommand that i was passing was something like :

HammerCLI::MainCommand.lazy_subcommand('add-override-value', _("Override the param"),
      'HammerCLIForeman::SmartClassParameter::AddOverrrideValueCommand',
       'haammer_cli_foreman/smart_class_parameter',
       true
    )

So, that is the reason it was not working for me.

@rabajaj0509 rabajaj0509 changed the title [WIP] Add hidden functionality to subcommands Fixes #20804 - Support for deprecating commands Sep 13, 2017
logger.info "subcommand #{name} (#{subcommand_class_name}) was created."
end

def define_subcommand(subcommand_class, definition, &block)
existing = find_subcommand(name)
Copy link
Member

Choose a reason for hiding this comment

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

@rahulbajaj0509 ,

Does name accessible inside this method? Everytime you will get nil value for existing.

Copy link
Member Author

@rabajaj0509 rabajaj0509 Sep 14, 2017

Choose a reason for hiding this comment

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

Thanks @kgaikwad :) i had not added the name parameter, therefore my test was failing.

@rabajaj0509
Copy link
Member Author

@tstrachota i am not sure why checks are failing here, there are no tests failing though.

@tstrachota
Copy link
Member

[test]

@tstrachota
Copy link
Member

@rahulbajaj0509 The code looks good now. I missed the failing test and even merged it but then I realized the test failure is related and had to revert it. There's problem with Clamp on ruby 2.0 where we have it pinned to < 1.1.0. Clamp dropped 2.0 support since then.

This is the commit that we're missing:
mdub/clamp@d0c4288

I haven't found any straightforward and clean way of adding the compatibility yet. @rahulbajaj0509 @mbacovsky any ideas?

@tstrachota
Copy link
Member

[test]

@tstrachota
Copy link
Member

👍 thanks @rahulbajaj0509

@tstrachota tstrachota merged commit 86d1f83 into theforeman:master Oct 18, 2017
@@ -59,23 +97,10 @@ def subcommand(name, description, subcommand_class = self, &block)
:new_class => subcommand_class
}
end
super
subcommand_class = Class.new(subcommand_class, &block) if block
declare_subcommand_parameters unless has_subcommands?
Copy link
Member

Choose a reason for hiding this comment

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

This line breaks systest: https://ci.theforeman.org/job/systest_foreman/13810/console

not ok 16 check smart proxy is registered and Hammer runs
# (in test file /usr/bin/fb-install-foreman.bats, line 167)
#   `count=$(hammer $(tHammerCredentials) --csv proxy list | wc -l)' failed
# /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/subcommand.rb:101:in `define_subcommand': undefined local variable or method `declare_subcommand_parameters' for HammerCLI::DefaultsCommand:Class (NameError)
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/subcommand.rb:77:in `subcommand'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/abstract.rb:212:in `block in autoload_subcommands'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/abstract.rb:211:in `each'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/abstract.rb:211:in `autoload_subcommands'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/defaults_commands.rb:158:in `<class:DefaultsCommand>'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/defaults_commands.rb:22:in `<module:HammerCLI>'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/defaults_commands.rb:3:in `<top (required)>'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/defaults.rb:1:in `<top (required)>'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli/context.rb:1:in `<top (required)>'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/lib/hammer_cli.rb:17:in `<top (required)>'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
# 	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.pre.develop/bin/hammer:117:in `<top (required)>'
# 	from /usr/bin/hammer:23:in `load'
# 	from /usr/bin/hammer:23:in `<main>'

Copy link
Member

Choose a reason for hiding this comment

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

@ekohl this change require new version of clamp. The packaging PRs are theforeman/foreman-packaging#1872 (RPM) and theforeman/foreman-packaging#1874 (DEB).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants