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

Support for extra-opts #32

Open
rpv-tomsk opened this issue Mar 17, 2021 · 4 comments
Open

Support for extra-opts #32

rpv-tomsk opened this issue Mar 17, 2021 · 4 comments
Labels
feature New feature or request question Further information is requested

Comments

@rpv-tomsk
Copy link

It would be nice to provide common/standart solution for plugins to support "Extra-Opts" (https://nagios-plugins.org/doc/extra-opts.html).

That highly required to "hide" passwords for command line arguments.
I think this project is a very good place to provide such a solution.

@mpounsett
Copy link
Owner

mpounsett commented Jun 8, 2021

I'm not sure that's really in scope of nagiosplugin. It seems to me that your sample code above is very specific to your plugin, and doesn't generalize well to plugins that don't use the same set of options, or use options that you're not using.

If using a nagiosplugin method to import extra-opts requires 90% of the same code that just loading a config file yourself and matching up options does, then I'm not sure I see the point of it. If you have an idea for a more generalized implementation that measurably reduces the amount of code a programmer needs to write in order to add extra-opts to their plugin, then I'm willing to reconsider.

I'm not even going to insist on a PR (although that would be appreciated)... if you can suggest a method signature with a bit of documentation about how you see it working that would help me understand what you're aiming for.

@rpv-tomsk
Copy link
Author

rpv-tomsk commented Jun 9, 2021

It seems to me that your sample code above is very specific to your plugin, and doesn't generalize well to plugins that don't use the same set of options, or use options that you're not using.

Yes, adding the code was a mistake.
I understand what my patch (in deleted comment) confused you and sent your thoughts in the wrong direction.
That was a dirty hack to solve my task of hiding the password from the command line.
Probably should have added a comment saying that without changing your library, the implementation looks exactly so complicated :-)

Let's review "support for extra-opts" issue again, without looking to my "sample code", and reopen it?

@rpv-tomsk
Copy link
Author

I'm not sure that's really in scope of nagiosplugin.

Did you take a look on https://nagios-plugins.org/doc/extra-opts.html ?

My proposal is to add common/standart solution for such/similar task into your library, which already has 'ArgumentParser' part.
That part should be smart to properly handle the --extra-opts option and support reading options from a given configuration file. Then any of Python plugins that use your library will be able to handle arguments defined in file without (or with minor) code changes.

I'm not a Python developer, so I can't suggest an implementation [without being ridiculed].

@mpounsett mpounsett reopened this Oct 5, 2021
@mpounsett
Copy link
Owner

Yes, I've read that doc before, and I'm familiar with it. I'm not sure I see a way to implement this in a way that's easily portable between plugins. The only ways to implement it that come to mind are going to require a lot of custom code for each use of it, which to my mind defeats the purpose.

I'll leave the issue open for a bit in case you can suggest a way to implement this that's not going to require each plugin developer to write a ton of code to use.

@mpounsett mpounsett added feature New feature or request question Further information is requested labels Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants