You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
feat(cmapi,cli): MCOL-5618: Add backup, restore, backup-dbrm, restore-dbrm commands for mcs cli tool. (#3130)
* MCOL-5618: Add backup, restore, backup-dbrm, restore-dbrm commands for mcs cli tool. [add] mcs_cluster_tool/helpers.py file with cook_sh_arg function inside [add] MCS_BACKUP_MANAGER_SH to mcs_cluster_tool/constants.py [add] backup and restore commands to "mcs" Typer APP * MCOL-5618: Move mcs_backup_manager.sh to cmapi/scripts. * MCOL-5618: Install mcs_backup_manager.sh with CMAPI package.
This commit is contained in:
29
cmapi/mcs_cluster_tool/helpers.py
Normal file
29
cmapi/mcs_cluster_tool/helpers.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Module with helper functions for mcs cli tool."""
|
||||
from typing import Union
|
||||
|
||||
|
||||
def cook_sh_arg(arg_name: str, value:Union[str, int, bool]) -> str:
|
||||
"""Convert argument and and value from function locals to bash argument.
|
||||
|
||||
:param arg_name: function argument name
|
||||
:type arg_name: str
|
||||
:param value: function argument value
|
||||
:type value: Union[str, int, bool]
|
||||
:return: bash argument string
|
||||
:rtype: str
|
||||
"""
|
||||
# skip "arguments" list and Typer ctx variables from local scope
|
||||
if arg_name in ('arguments', 'ctx'):
|
||||
return None
|
||||
# skip args that have empty string as value
|
||||
if value == '':
|
||||
return None
|
||||
if '_' in arg_name:
|
||||
arg_name = arg_name.replace('_', '-')
|
||||
# skip boolean args that have False value
|
||||
if isinstance(value, bool):
|
||||
if not value:
|
||||
return None
|
||||
# if True value presented just pass only arg name without value
|
||||
value = ''
|
||||
return f'-{arg_name} {value}' if value else f'-{arg_name}'
|
Reference in New Issue
Block a user