| 29 | |
| 30 | |
| 31 | def main(subcmd): |
| 32 | def f(args, repo): |
| 33 | curr_b = repo.current_branch |
| 34 | success = True |
| 35 | |
| 36 | for fp in args.files: |
| 37 | try: |
| 38 | getattr(curr_b, subcmd + '_file')(fp) |
| 39 | pprint.ok( |
| 40 | 'File {0} is now a{1} {2}{3}d file'.format( |
| 41 | fp, 'n' if subcmd.startswith(VOWELS) else '', subcmd, |
| 42 | '' if subcmd.endswith('e') else 'e')) |
| 43 | except KeyError: |
| 44 | pprint.err('Can\'t {0} non-existent file {1}'.format(subcmd, fp)) |
| 45 | success = False |
| 46 | except ValueError as e: |
| 47 | pprint.err(e) |
| 48 | success = False |
| 49 | |
| 50 | return success |
| 51 | return f |