mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
container: Show default values in command help
Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil: Use the default formatter on all the subparsers] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
7f959ad304
commit
2f1feeadf1
25
container
25
container
@ -257,19 +257,22 @@ systemd_version = None
|
||||
|
||||
def parse_arguments():
|
||||
"""Return parsed command line arguments as dictionary."""
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
distributions = list(URLS.keys())
|
||||
|
||||
distribution = os.environ.get('DISTRIBUTION')
|
||||
|
||||
formatter_class = argparse.ArgumentDefaultsHelpFormatter
|
||||
default_distribution = 'testing'
|
||||
if distribution and distribution in distributions:
|
||||
default_distribution = distribution
|
||||
|
||||
# Up
|
||||
subparser = subparsers.add_parser('up', help='Bring up the container')
|
||||
subparser = subparsers.add_parser('up', help='Bring up the container',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument(
|
||||
'--distribution', choices=distributions, default=default_distribution,
|
||||
help='Distribution of the image to download and setup')
|
||||
@ -278,20 +281,23 @@ def parse_arguments():
|
||||
|
||||
# Print IP address
|
||||
subparser = subparsers.add_parser(
|
||||
'ip', help='Print the IP address of the container.')
|
||||
'ip', help='Print the IP address of the container.',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument(
|
||||
'--distribution', choices=distributions, default=default_distribution,
|
||||
help='Distribution of the container to print IP address')
|
||||
|
||||
# ssh
|
||||
subparser = subparsers.add_parser('ssh', help='SSH into the container')
|
||||
subparser = subparsers.add_parser('ssh', help='SSH into the container',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default=default_distribution,
|
||||
help='Distribution of the container to SSH into')
|
||||
|
||||
# Run tests
|
||||
subparser = subparsers.add_parser('run-tests',
|
||||
help='Run tests in the container')
|
||||
help='Run tests in the container',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default=default_distribution,
|
||||
help='Distribution of the container to run tests')
|
||||
@ -300,21 +306,24 @@ def parse_arguments():
|
||||
help='Additional arguments to pass to the pytest command')
|
||||
|
||||
# Stop
|
||||
subparser = subparsers.add_parser('stop', help='Stop the container')
|
||||
subparser = subparsers.add_parser('stop', help='Stop the container',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default=default_distribution,
|
||||
help='Distribution of the container to stop')
|
||||
|
||||
# Destroy
|
||||
subparser = subparsers.add_parser('destroy',
|
||||
help='Destroy the container image')
|
||||
help='Destroy the container image',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default=default_distribution,
|
||||
help='Distribution of the image to delete')
|
||||
|
||||
# Update
|
||||
subparser = subparsers.add_parser(
|
||||
'update', help='Update the container image to the latest version')
|
||||
'update', help='Update the container image to the latest version',
|
||||
formatter_class=formatter_class)
|
||||
subparser.add_argument('--distribution', choices=distributions,
|
||||
default=default_distribution,
|
||||
help='Distribution of the image to update')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user