Skip to content

Commit

Permalink
feature: Add version output as cli arg
Browse files Browse the repository at this point in the history
Fixes: #89
  • Loading branch information
gyptazy committed Oct 10, 2024
1 parent 486acad commit 17c9c98
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .changelogs/1.0.4/89_add_version_output.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
added:
- Add version output cli arg. [#89]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ The following options and parameters are currently supported:
| -j | --json | Returns a JSON of the VM movement. | Unset |
| -b | --best-node | Returns the best next node for a VM/CT placement (useful for further usage with Terraform/Ansible). | Unset |
| -m | --maintenance | Sets node(s) to maintenance mode & moves workloads away. | Unset |
| -v | --version | Returns the ProxLB version on stdout. | Unset |

### Balancing
#### General
Expand Down
10 changes: 10 additions & 0 deletions proxlb
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,17 @@ def initialize_args():
argparser.add_argument('-j', '--json', help='Return a JSON of the VM movement.', action='store_true', required=False)
argparser.add_argument('-b', '--best-node', help='Returns the best next node.', action='store_true', required=False)
argparser.add_argument('-m', '--maintenance', help='Sets node to maintenance mode & moves workloads away.', type=str, required=False)
argparser.add_argument('-v', '--version', help='Returns the current ProxLB version.', action='store_true', required=False)
return argparser.parse_args()


def proxlb_output_version():
""" Print ProxLB version information on CLI. """
print(f'{__appname__} version {__version__}\nRequired config version: >= {__config_version__}')
print('ProxLB support: https://github.com/gyptazy/ProxLB\nDeveloper: gyptazy.com')
sys.exit(0)


def initialize_config_path(app_args):
""" Initialize path to ProxLB config file. """
info_prefix = 'Info: [config]:'
Expand Down Expand Up @@ -1495,6 +1503,8 @@ def main():
# Initialize PAS.
initialize_logger('CRITICAL')
app_args = initialize_args()
if app_args.version:
proxlb_output_version()
config_path = initialize_config_path(app_args)
pre_validations(config_path)

Expand Down

0 comments on commit 17c9c98

Please sign in to comment.