-
Notifications
You must be signed in to change notification settings - Fork 2
/
b2help-releases
executable file
·54 lines (45 loc) · 2 KB
/
b2help-releases
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env b2anypython
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import textwrap
import argparse
from versioning import supported_release
from setup_tools import NoExitHelpAction
def get_argument_parser():
description = textwrap.dedent('''\n
This command just prints the current recommended release of the Belle II software.
If you provide release_to_check, it will check if this version is supported or to which more recent version you should update.
The RELEASE_TO_CHECK doesn't have to be complete. It is enough if it contains the prefix 'release-' or 'light'.
''')
parser = argparse.ArgumentParser(prog='b2help-releases',
description=description,
add_help=False,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('release',
metavar='RELEASE_TO_CHECK',
type=str,
nargs='?',
help='Allows providing a release to check.')
parser.add_argument('--help', '-h', '-?',
nargs=0,
action=NoExitHelpAction)
return parser
if __name__ == '__main__':
args = get_argument_parser().parse_args()
if args.help:
print("\nThe recommended release is:", file=sys.stderr)
print(supported_release())
# check whether the provided release is supported
elif args.release:
release = sys.argv[1]
supported = supported_release(release)
if release == 'light':
print("The recommended light release is %s" % supported)
elif supported != release:
print("Warning: The release %s is not supported any more. Please update to %s" % (release, supported))
else:
print("The release %s is supported" % release)
# if no options provided just print the supported release
else:
print(supported_release())