DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (cdf352f02ac4)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#!/usr/bin/env python3
# ./dev --help

import argparse
import os
from subprocess import run
import sys

parser = argparse.ArgumentParser(prog='./dev')
subparsers = parser.add_subparsers(metavar='<command>', title='commands')
command = [
    'docker', 'run', '-it', '--rm', '-v', os.getcwd() + ':/src:cached',
    '-w=/src', 'rust:1.21.0'
]

def cargo(args, remaining):
    sys.exit(run(command + ['cargo'] + remaining or []).returncode)

parser_cargo = subparsers.add_parser('cargo', help='run a cargo command')
parser_cargo.set_defaults(func=cargo)

def sh(args, remaining):
    sys.exit(run(command + ['bash']).returncode)

parser_sh = subparsers.add_parser('sh', help='bring up a shell')
parser_sh.set_defaults(func=sh)

def test(args, remaining):
    sys.exit(run(command + ['cargo', 'test']).returncode)

parser_test = subparsers.add_parser('test', help='run tests')
parser_test.set_defaults(func=test)

if len(sys.argv) > 1:
    args, remaining = parser.parse_known_args()
    try:
        args.func(args, remaining)
    except FileNotFoundError:
        sys.exit('Please install Docker.')
else:
    parser.print_help()