Mercurial > repos > shellac > sam_consensus_v3
comparison env/bin/register-python-argcomplete @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 #!/Users/cmdms/OneDrive-UOB/Development/Projects/2021/sam-consensus-v3/env/bin/python3 | |
2 # PYTHON_ARGCOMPLETE_OK | |
3 | |
4 # Copyright 2012-2019, Andrey Kislyuk and argcomplete contributors. | |
5 # Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info. | |
6 | |
7 ''' | |
8 Register a Python executable for use with the argcomplete module. | |
9 | |
10 To perform the registration, source the output of this script in your bash shell | |
11 (quote the output to avoid interpolation). | |
12 | |
13 Example: | |
14 | |
15 $ eval "$(register-python-argcomplete my-favorite-script.py)" | |
16 | |
17 For Tcsh | |
18 | |
19 $ eval `register-python-argcomplete --shell tcsh my-favorite-script.py` | |
20 | |
21 For Fish | |
22 | |
23 $ register-python-argcomplete --shell fish my-favourite-script.py > ~/.config/fish/my-favourite-script.py.fish | |
24 ''' | |
25 | |
26 import sys | |
27 import argparse | |
28 import argcomplete | |
29 | |
30 | |
31 parser = argparse.ArgumentParser( | |
32 description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
33 | |
34 parser.add_argument( | |
35 '--no-defaults', | |
36 dest='use_defaults', action='store_false', default=True, | |
37 help='When no matches are generated, do not fallback to readline\'s default completion') | |
38 parser.add_argument( | |
39 '--complete-arguments', | |
40 nargs=argparse.REMAINDER, | |
41 help='arguments to call complete with; use of this option discards default options') | |
42 parser.add_argument( | |
43 '-s', '--shell', | |
44 choices=('bash', 'tcsh', 'fish'), default='bash', | |
45 help='output code for the specified shell') | |
46 parser.add_argument( | |
47 '-e', '--external-argcomplete-script', | |
48 help='external argcomplete script for auto completion of the executable') | |
49 | |
50 parser.add_argument( | |
51 'executable', | |
52 nargs='+', | |
53 help='executable to completed (when invoked by exactly this name)') | |
54 | |
55 argcomplete.autocomplete(parser) | |
56 | |
57 if len(sys.argv) == 1: | |
58 parser.print_help() | |
59 sys.exit(1) | |
60 | |
61 args = parser.parse_args() | |
62 | |
63 | |
64 sys.stdout.write(argcomplete.shellcode( | |
65 args.executable, args.use_defaults, args.shell, args.complete_arguments, args.external_argcomplete_script)) |