""" Run commands in student or project repos
"""
# vim: ft=python
from __future__ import division, print_function, absolute_import

import os
from argparse import ArgumentParser

from gradebook import grades, repo_dir
from gradebook.utils import cd, log, sh

argparser = ArgumentParser(
    description='Run command in student or project repos.'
)
argparser.add_argument(
    '-p', '--projects', action='store_true',
    help='run on projects (default: students)'
)
argparser.add_argument('command', nargs='+',
                       help='command to run in repos')


def main():
    args = argparser.parse_args()

    log.info('#'*80)
    log.info(vars(args))
    log.info('#'*80)
    repos = 'projects' if args.projects else 'students'
    for repo in grades[repos].values():
        login = repo['login']
        status = repo.get('status', 'enrolled')
        if status in ['enrolled', 'audit']:
            run(args.command, os.path.join(repo_dir, repos, login)) 

def run(command, directory):
    with cd(directory):
       sh(command)


@@ -455,24 +455,133 @@
 tudents)'%0A)%0A
+argparser.add_argument(%0A    '-s', '--select', action='store',%0A    help='only run on the specified section'%0A)%0A
 argparser.ad
@@ -613,16 +613,16 @@
 gs='+',%0A
-
         
@@ -840,16 +840,21 @@
 udents'%0A
+    %0A
     for 
@@ -974,16 +974,149 @@
      if 
+args.select:%0A            selected = repo%5B'section'%5D == args.select%0A        else:%0A            selected = True%0A        if selected and 
 status i
@@ -1259,24 +1259,25 @@
 directory):%0A
+ 
        sh(co

Fix #6