introduce --verbosity flag rather than mixed logging settings; correct color misnaming to ANSI convention; added sanity-check; simplified hello-world; created FZF_USER_INPUT to replace the confusing FZF_HEAD and FZF_TAIL swap INFO for DEBUG v3-to-v4 upgrade docs bring some much-needed tender love and care to the scwrypts runner improved i/o handling on the run executable means this is no longer relevant FINALLY fix the weird cases for zsh/read builtin (particularly around reading one character from tty/pipe/file); also gave a --force-user-input flag in case you want to require user input on a yn prompt update ZLE plugin so it no more make errors FZF_(HEAD|TAIL) refactor to FZF_USER_INPUT plugins/kubectl migration from v3 to v4 plugins/ci migration from v3 to v4 refactor py/lib into python-scwrypts subproject verbosity is stupid lets call it log-level fix bug with virtualenv loading mergedeep to slow so I made my options dict shallow hokay first iteration of python-dudes is ready circleci configuration for python builds npm package for scwrypts 3.9.1 initial build/test steps for nodejs go go ok ok fix output ok ok finalize publish steps
		
			
				
	
	
		
			63 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python
 | 
						|
from scwrypts import execute
 | 
						|
#####################################################################
 | 
						|
from sys import stderr
 | 
						|
 | 
						|
from scwrypts.env import getenv
 | 
						|
from scwrypts.twilio import send_sms
 | 
						|
 | 
						|
 | 
						|
description = 'send a simple SMS through twilio'
 | 
						|
parse_args = [
 | 
						|
        ( ['-t', '--to'], {
 | 
						|
            'dest'     : 'to',
 | 
						|
            'help'     : 'phone number of the receipient',
 | 
						|
            'required' : False,
 | 
						|
            'default'  : getenv('TWILIO__DEFAULT_PHONE_TO', required=False),
 | 
						|
            }),
 | 
						|
        ( ['-f', '--from'], {
 | 
						|
            'dest'     : 'from_',
 | 
						|
            'help'     : 'phone number of the receipient',
 | 
						|
            'required' : False,
 | 
						|
            'default'  : getenv('TWILIO__DEFAULT_PHONE_FROM', required=False),
 | 
						|
            }),
 | 
						|
        ( ['-b', '--body'], {
 | 
						|
            'dest'     : 'body',
 | 
						|
            'help'     : 'message body',
 | 
						|
            'required' : False,
 | 
						|
            }),
 | 
						|
        ( ['--max-char-count'], {
 | 
						|
            'dest'     : 'max_char_count',
 | 
						|
            'help'     : 'separate message into parts by character count (1 < N <= 1500)',
 | 
						|
            'required' : False,
 | 
						|
            'default'  : 300,
 | 
						|
            }),
 | 
						|
        ]
 | 
						|
 | 
						|
def main(args, stream):
 | 
						|
    if args.body is None:
 | 
						|
        print(f'reading input from {stream.input.name}', file=stderr)
 | 
						|
        args.body = ''.join(stream.readlines()).strip()
 | 
						|
 | 
						|
    if len(args.body) == 0:
 | 
						|
        args.body = 'PING'
 | 
						|
 | 
						|
    if args.from_ is None:
 | 
						|
        raise MissingFlagAndEnvironmentVariableError(['-f', '--from'], 'TWILIO__DEFAULT_PHONE_FROM')
 | 
						|
 | 
						|
    if args.to is None:
 | 
						|
        raise MissingFlagAndEnvironmentVariableError(['-t', '--to'], 'TWILIO__DEFAULT_PHONE_TO')
 | 
						|
 | 
						|
    send_sms(
 | 
						|
            to = args.to,
 | 
						|
            from_ = args.from_,
 | 
						|
            body = args.body,
 | 
						|
            max_char_count = args.max_char_count,
 | 
						|
            stream = stream,
 | 
						|
            )
 | 
						|
 | 
						|
 | 
						|
#####################################################################
 | 
						|
if __name__ == '__main__':
 | 
						|
    execute(main, description, parse_args)
 |