Hi Marek, Thanks again for your reply..
I already tried to use __init__ method... arguments was added without error ( I can get any message when add on optparser), but, dnf still say: unrecognized arguments I believe it's because plugin is loaded after args was passed inside dnf, so, dnf not recognize the new argument.. only approach I can get global args, is add inside *def _main_parser(self)*: * on option_parser.py * on dnf package.. but, I avoid to change anything from mainstream.. Cheers, T.·.F.·.A.·. S+F *Fellipe Henrique P. Soares* e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge' *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh <https://fedoraproject.org/wiki/User:Fellipeh>* *Blog: *http:www.fellipeh.eti.br *GitHub: https://github.com/fellipeh <https://github.com/fellipeh>* *Twitter: @fh_bash* On Tue, Jul 23, 2019 at 9:10 AM Marek Blaha <[email protected]> wrote: > Hi, > > there is no supported way how to change global arguments in DNF. > However, you can try in __init__ method of your plugin do something > like this: > > class MyPlugin(dnf.Plugin): > def __init__(self, base, cli): > super(MyPlugin, self).__init__(base, cli) > cli.optparser.add_argument('--set-layer') > > -- > Marek Blaha <[email protected]> > > Red Hat Czech s.r.o. > Software Engineer > On Tue, Jul 23, 2019 at 12:02 PM Fellipe Henrique <[email protected]> > wrote: > > > > Hi Marek, > > > > First, Thanks very much for you reply... > > > > I need to add a "global" argument so I can change the layer of a > repository... For example: > > > > $ dnf repolist --set-layer=mylayer > > $ dnf install -y any_repo --set-layer=mylayer > > > > So on my plug-in I can change layer in repository to do anything, for > that running process, to a different layer. (For example).. > > > > That's the reason I need a "global" argument, not a command, so I can > use these arg on any dnf command, like "-v" argument.. > > > > I saw your email related to reposync, but reposync use a command, so I > need to add a command "reposync" and its arguments... As I explain above, I > need a global argument to work with all dnf commands... > > > > That's my real problem, I do not know if dnf plug-in give me access to > do that... > > > > On yum, I made these using init_hook() def, and setting the args.. But > dnf doesn't no have init_hook anymore.... > > > > Again, thanks for your time and help, any tips will be welcome.. > > > > Cheers! > > > > Fellipe H. > > > > Em ter, 23 de jul de 2019 às 03:37, Marek Blaha <[email protected]> > escreveu: > >> > >> Each DNF command could have static method set_argparser (here is the > >> example from reposync plugin: > >> > https://github.com/rpm-software-management/dnf-plugins-core/blob/master/plugins/reposync.py#L60 > ) > >> which can be used for adding command specific arguments. However there > >> is no such method for adding global arguments. > >> May I ask you to elaborate your use case in more details? What are you > >> trying to achieve? > >> > >> Regards, > >> > >> Marek > >> > >> -- > >> Marek Blaha <[email protected]> > >> > >> Red Hat Czech s.r.o. > >> Software Engineer > >> > >> On Mon, Jul 22, 2019 at 7:59 PM Fellipe Henrique <[email protected]> > wrote: > >> > > >> > Hello, > >> > > >> > First of all, thanks for accept me on these mail list.. my first mail > it's about a issue I facing here on my job... > >> > > >> > I need to add some optional arguments on dnf, not a command, just a > "global" args.. eg: $ dnf repolist --my_arg=abcd > >> > > >> > How can I do these? Can I use plugin with these approach? > >> > > >> > I already try to override OptionParser from cli inside Plugin class, > no success... I try just parse cli args, but dnf still says my argument if > not recognized.. > >> > > >> > Anyone, have any tips how to do that? > >> > > >> > Best regards, > >> > > >> > T.·.F.·.A.·. S+F > >> > Fellipe Henrique P. Soares > >> > > >> > e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ > 's/(.)/chr(ord($1)-2*3)/ge' > >> > Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh > >> > Blog: http:www.fellipeh.eti.br > >> > GitHub: https://github.com/fellipeh > >> > Twitter: @fh_bash > >> > _______________________________________________ > >> > devel mailing list -- [email protected] > >> > To unsubscribe send an email to [email protected] > >> > Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > >> > List Guidelines: > https://fedoraproject.org/wiki/Mailing_list_guidelines > >> > List Archives: > https://lists.fedoraproject.org/archives/list/[email protected] > >> _______________________________________________ > >> devel mailing list -- [email protected] > >> To unsubscribe send an email to [email protected] > >> Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > >> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > >> List Archives: > https://lists.fedoraproject.org/archives/list/[email protected] > > > > -- > > Sent from my iPhone > > _______________________________________________ > > devel mailing list -- [email protected] > > To unsubscribe send an email to [email protected] > > Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > > List Archives: > https://lists.fedoraproject.org/archives/list/[email protected] > _______________________________________________ > devel mailing list -- [email protected] > To unsubscribe send an email to [email protected] > Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: > https://lists.fedoraproject.org/archives/list/[email protected] >
_______________________________________________ devel mailing list -- [email protected] To unsubscribe send an email to [email protected] Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/[email protected]
