Use PyPy 3.7 in CI
[stgit.git] / build.py
blob74127ebd0dc82af0e3754ea395ec82968b42ebdf
1 #!/usr/bin/env python3
2 import optparse
3 import os
4 import sys
6 import stgit.main
7 import stgit.version
8 from stgit import argparse, commands
9 from stgit.completion.bash import write_bash_completion
10 from stgit.completion.fish import write_fish_completion
13 def main():
14 op = optparse.OptionParser()
15 op.add_option(
16 '--stgit-version',
17 action='store_true',
18 help='Print StGit version',
20 op.add_option(
21 '--asciidoc',
22 metavar='CMD',
23 help='Print asciidoc documentation for a command',
25 op.add_option(
26 '--commands',
27 action='store_true',
28 help='Print list of all stg subcommands',
30 op.add_option(
31 '--cmd-list',
32 action='store_true',
33 help='Print asciidoc command list',
35 op.add_option(
36 '--py-cmd-list',
37 action='store_true',
38 help='Write Python command list',
40 op.add_option(
41 '--bash-completion',
42 action='store_true',
43 help='Write bash completion code',
45 op.add_option(
46 '--fish-completion',
47 action='store_true',
48 help='Write fish completion code',
50 options, args = op.parse_args()
51 if args:
52 op.error('Wrong number of arguments')
53 if options.stgit_version:
54 print(stgit.version.get_version())
55 elif options.asciidoc:
56 argparse.write_asciidoc(stgit.main.commands[options.asciidoc], sys.stdout)
57 elif options.commands:
58 for cmd, _, _, _ in commands.get_commands(allow_cached=False):
59 print(cmd)
60 elif options.cmd_list:
61 commands.asciidoc_command_list(
62 commands.get_commands(allow_cached=False), sys.stdout
64 elif options.py_cmd_list:
65 commands.py_commands(commands.get_commands(allow_cached=False), sys.stdout)
66 elif options.bash_completion:
67 write_bash_completion(sys.stdout)
68 elif options.fish_completion:
69 write_fish_completion(sys.stdout)
70 else:
71 op.error('No command')
74 if __name__ == '__main__':
75 if os.environ.get('COVERAGE_PROCESS_START'):
76 import coverage
78 cov = coverage.process_startup()
79 cov.switch_context('build')
81 main()