This repository has been archived by the owner on Apr 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
kubenvz.py
48 lines (35 loc) · 1.74 KB
/
kubenvz.py
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
#!/usr/bin/env python
import argparse
from commands import list_local, list_remote, install, use, uninstall
from sys import exit
class Parser(argparse.ArgumentParser):
def error(self, message):
self.print_help()
exit(1)
parser = Parser(description='Manage kubectl, kustomize and helm versions v0.2.0')
parser.add_argument('program', choices=['kubectl', 'kustomize','helm','helmfile'], help='program')
commands = parser.add_subparsers(title='commands', dest='commands')
commands.required = True
# list
list_cmd_parser = commands.add_parser('list', help='List Versions')
list_cmds = list_cmd_parser.add_subparsers(dest='location')
list_cmds.required = True
list_local_cmd = list_cmds.add_parser('local', help='List Local Versions')
list_local_cmd.set_defaults(func=list_local)
list_remote_cmd = list_cmds.add_parser('remote', help='List Remote Versions')
list_remote_cmd.set_defaults(func=list_remote)
# Install
install_cmd_parser = commands.add_parser('install', help='Install specific version or version defined in .kubenvz file')
install_cmd_parser.add_argument('version', type=str, help='Version to install', nargs="?", default="")
install_cmd_parser.add_argument('-f', action='store_true')
install_cmd_parser.set_defaults(func=install)
# Uninstall
uninstall_cmd_parser = commands.add_parser('uninstall', help='Uninstall specific version')
uninstall_cmd_parser.add_argument('version', type=str, help='Version to install', nargs="?", default="")
uninstall_cmd_parser.set_defaults(func=uninstall)
# Use
use_cmd_parser = commands.add_parser('use', help='Use program version')
use_cmd_parser.add_argument('version', type=str, help='Version to use', nargs="?", default="")
use_cmd_parser.set_defaults(func=use)
args = parser.parse_args()
args.func(args)