def logo_print(): if sdk.get_interface_type() == 'terminal': ux.print(cto_terminal) else: ux.print(cto_slack) ux.print(intro)
def set_credentials_instructions(self): """ Prints message on the appropriate format for setting all fields as one """ ux.print("Please set your secrets in the following format:") if sdk.get_interface_type() == "slack": ux.print( '```{"Host": <host>,\n "Username": <username>,\n "Password": <password>,\n "Database": <database>,\n "Port": <port>}```' ) else: ux.print( '{"Host": <host>,\n "Username": <username>,\n "Password": <password>,\n "Database": <database>,\n "Port": <port>}' )
def print_for_usability(response) -> None: """ Prints the unformatted response. If the interface is Slack, prints in 2800 character sections """ raw = str(response.json()) raw = raw.replace("'", '"') interface = sdk.get_interface_type() if interface == "slack": segments = ceil(len(raw) / slack_max_characters) seg_check = prompt.confirm( "seg_check", "The data will be broken up into {} segments ({} characters each). Continue with print?" .format(segments, slack_max_characters)) if seg_check == False: return slack_print(raw)
def slack_format(s: str) -> list: """ Formats a string for printing based in Interface Type (Slack or Terminal), returns list of separated blocks """ final_msg = [] interface = sdk.get_interface_type() if interface == "slack": i = 0 while i + slack_max_characters < len(s): msg = s[i:i + slack_max_characters] final_msg.append('```{}```'.format(msg)) i += slack_max_characters final_msg.append('```{}```'.format(s[i:])) else: final_msg.append(s) return final_msg