#33 Make fedpkg be able to handle things like "fedpkg build update" or "fedpkg local lint"
Closed: Invalid 7 years ago Opened 13 years ago by jkeating.

The old make system could do this, based on how make works. Since fedpkg parses args and each command can have it's own argument space, this gets harder. What we could probably do is figure out the popular multi-commands and make their parsers have an entry for the second command that would be used.


How about this. Create a wrapper script like this:

{{{#!/usr/bin/env python
import sys
import fedpkg as app
multi_commands = ['build', 'update']
for arg in sys.argv:
if arg in multi_commands:
# multi-routine: call fedpkg multiple times
sys.exit(0)

run normally

sys.exit(app.main() or 0)}}}

Then place fedpkg.py as /usr/lib/python-2.6/site-packages/fedpkg/app.py , and call the script with
wrapper arg1 arg2 arg3

Maybe the multi-routine only gets executed if args contain only multi-commands (in other words, don't call the routine if non-multi-commands are passed on as arguments), or don't call the routine if args contain '-' , meaning it's quite sure that no multicommand is provided.

IMO that's nicer than modifying all the parsers. What do you think?

wikiformat got screwed up, here it is again:
{{{

!/usr/bin/env python

import sys
import fedpkg as app
multi_commands = ['build', 'update', 'switch-branch']
for arg in sys.argv:
if arg in multi_commands:
print "Multi command %s found" % arg
sys.exit(app.main() or 0)
}}}

How would you handle arguments passed to each command? Lets say build takes a couple arguments and update takes a few arguments? How do you properly separate out the arguments for each possible command (and what happens if one of your arguments for one command is in fact the name of another command...)

Good question (and sorry for responding so late, i didn't get a mail somehow), i'll setup a testcase and let you know later today. I believe that this is quite possible, i just don't know how exactly.

I still think I'd prefer to add the common combinations in to the existing fedpkg.py by adding an argument that takes many options, and we would parse those options into further commands to run. ArgParse is helpful here.

You're probably right, it just looks .. strange .. to me if you have to make an educated guess which options users would use. Consider this:

{{{

!/usr/bin/env python

example:

fedpkg switch-branch mytest chain-build pkg1 pkg2 update

what the user means by this is:

fedpkg switch-branch mytest

fedpkg chain-build pkg1 pkg2

fedpkg update

so a better syntax could be:

fedpkg switch-branch mytest + chain-build pkg1 pkg2 + update

import sys
import fedpkg as app

del sys.argv[0]
line = " ".join(sys.argv)
all_commands = line.split('+')

for command in all_commands:
print "+++ RUNNING COMMAND %s" % command.strip()
}}}

This would result in:

{{{
$ ./wrapper switch-branch mytest + chain-build pkg1 pkg2 + update
+++ RUNNING COMMAND switch-branch mytest
+++ RUNNING COMMAND chain-build pkg1 pkg2
+++ RUNNING COMMAND update
}}}

Of course, the last line should be replaced with a call to fedpkg. This way would allow users to specify any number of commands, separated by a '+' and fedpkg would (try to?) run each set of commands.

If you still feel this is all just wrong, i would be happy to implement it in the way you suggest (if you want me to, that is).

Fedpkg has moved to a separate project. If you're still interested in this feature, file your request at fedpkg.

@lsedlar changed the status to Closed

7 years ago

Login to comment on this ticket.

Metadata