• 
      

    Allow third-party packages to register new rbt commands.

    Review Request #5046 — Created Dec. 3, 2013 and submitted

    Information

    RBTools
    master

    Reviewers

    Allow third-party packages to register new rbt commands.

    rbt will now scan for commands that are registered for
    the 'rbtools_commands' entrypoint.

    Created a simple Python package that registered a new command, and sure enough, it showed up in rbt help, and could be invoked via rbt [command].

    I created a third-party commands that tried to override the built-in "post" command, and tested to make sure that only one "post" command was listed with rbt help, and that only the built-in post command could be invoked.

    Description From Last Updated

    Maybe we should default to commands provided by the rbtools package. So, if rbtools specifies the entry point, we use …

    SM smacleod

    The {.. for ...} is only in Python 2.7+. It'll need to be rewritten to work with 2.4+.

    chipx86chipx86

    This will end up getting the RBTools ones twice. We should probably filter that out.

    chipx86chipx86
    SM
    1. 
        
    2. rbtools/commands/main.py (Diff revision 1)
       
       

      If another package specifies the same command as rbtools, we'll have a repeat in this list. Think we need to bother de-duplicating?

    3. rbtools/commands/main.py (Diff revision 1)
       
       
      Show all issues

      Maybe we should default to commands provided by the rbtools package. So, if rbtools specifies the entry point, we use that as the command, and only check other packages if it doesn't. Something like:

      ep = (pkg_resources.get_entry_info("rbtools", "rbtools_commands", args[0]) ||
            pkg_resources.iter_entry_points("rbtools_commands", args[0]).next())
      
      1. Sorry, brain in JS land there for a second. Code should be:

        ep = (pkg_resources.get_entry_info("rbtools", "rbtools_commands", args[0]) or
              pkg_resources.iter_entry_points("rbtools_commands", args[0]).next())
        
    4. 
        
    mike_conley
    chipx86
    1. 
        
    2. rbtools/commands/main.py (Diff revision 2)
       
       
      Show all issues

      The {.. for ...} is only in Python 2.7+. It'll need to be rewritten to work with 2.4+.

    3. rbtools/commands/main.py (Diff revision 2)
       
       
       
      Show all issues

      This will end up getting the RBTools ones twice. We should probably filter that out.

      1. It shouldn't. We're only searching for the value of args[0], so if the command
        exists in rbtools get_entry_info() will shortcircuit the or, and we'll never
        call iter_entry_points. In the case where rbtools doesn't have the command, it
        won't be there for iter_entry_points.

      2. That's fair.

    4. 
        
    mike_conley
    SM
    1. Ship It!
    2. 
        
    mike_conley
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to master (6474d851ff5074a460b9dec2e684df689f4e7636).