def start() -> None: """Start prompting the user for input.""" # ---------------------------------------------------------------------------------------------------------------------- # sh.add_cmd( pcmd.Command('clear', 'cls', callback=pash.cmds.clear, hint='Clear the console ... ')) # ---------------------------------------------------------------------------------------------------------------------- # sh.add_cmd( pcmd.Command('exit', 'quit', 'exit()', callback=on_exit, hint='Quit the shell ... ')) # ---------------------------------------------------------------------------------------------------------------------- # show_audio = pcmd.Command('audio', callback=on_show_audio, hint='Show what audio input is detected ... ') show_audio.add_arg('-s', '--scale', type=float, dest='scale', default=5., help='Specify output scale ... ') show_audio.add_arg( '-c', '--char', type=str, dest='char', default='▬', help='Specify the character to be used for the graph ... ') sh.add_cmd( pcmd.CascCommand( 'show', 'sh', cmds=[ _with_json( pcmd.Command('devices', 'dev', callback=on_show_devices, hint='List all devices ... ')), show_audio, _with_json( pcmd.Command( 'status', 'stat', callback=on_show_status, hint='Show the audio channel\'s status ... ')), _with_json( pcmd.CascCommand( 'sounds', cmds=[ _with_json( pcmd.Command( 'all', 'a', callback=on_show_all_sounds, hint='List all available sounds ... ')), ], callback=on_show_sounds, hint='List all currently playing sounds ... ')), pcmd.Command( 'interpreters', 'in', callback=on_show_interpreters, hint='List all running/available interpreters ... '), _with_json( pcmd.CascCommand( 'filters', 'fil', cmds=[ _with_json( pcmd.Command( 'all', 'a', callback=on_show_all_filters, hint='List all available voice filters ... ' )), ], callback=on_show_running_filters, hint='List all running/available voice filters ... ')), ], hint='Show info ... ')) # ---------------------------------------------------------------------------------------------------------------------- # start_sound = pcmd.Command('sound', callback=on_start_sound, hint='Play a soundeffect ... ') start_sound.add_arg('parameters', type=str, nargs='*', help='Specify the filenames & volumes ... ') start_output = pcmd.Command('output', 'ost', callback=on_start_output, hint='Add an output device ... ') start_output.add_arg('indo', type=int, help='Specify the output device\'s index ... ') start_input = pcmd.Command('input', 'ist', callback=on_start_input, hint='Add an input device ... ') start_input.add_arg('indi', type=int, help='Specify the input device\'s index ... ') start_interpreter = pcmd.Command('interpreter', 'in', callback=on_start_interpreter, hint='Interpret a .fig file ... ') start_interpreter.add_arg('fname', type=str, help='Specify the filenames ... ') start_filter = pcmd.Command('filter', 'fil', callback=on_start_filter, hint='Add a filter to your audio input ... ') start_filter.add_arg('name', type=str, help='Specify the filter\'s name ... ') start_filter.add_arg('cargs', nargs='*', help='Specify the filter\'s arguments ... ') sh.add_cmd( _with_json( pcmd.CascCommand( 'start', cmds=[ _with_json(start_sound), _with_json(start_output), _with_json(start_input), start_interpreter, start_filter, pcmd.Command('server', 'srv', callback=on_start_server, hint='Start the websocket server ... ') ], callback=on_start, hint='Start channeling audio / other things ... '))) # ---------------------------------------------------------------------------------------------------------------------- # stop_sound = pcmd.Command('sound', callback=on_stop_sound, hint='Remove a soundeffect ... ') stop_sound.add_arg('ind', type=str, help='Specify the sound effect\'s index ... ') stop_output = pcmd.Command('output', 'ost', callback=on_stop_output, hint='Remove an output device ... ') stop_output.add_arg('indo', type=int, help='Specify the output device\'s index ... ') stop_input = pcmd.Command('input', 'ist', callback=on_stop_input, hint='Remove an input device ... ') stop_input.add_arg('indi', type=int, help='Specify the input device\'s index ... ') stop_interpreter = pcmd.Command('interpreter', 'in', callback=on_stop_interpreter, hint='Stop a running interpreter ... ') stop_interpreter.add_arg('ind', type=str, help='Specify the interpreter\'s index ... ') stop_filter = pcmd.Command('filter', 'fil', callback=on_stop_filter, hint='Stop a running filter ... ') stop_filter.add_arg('ind', type=str, help='Specify the filter\'s index ... ') sh.add_cmd( _with_json( pcmd.CascCommand( 'stop', 'kill', cmds=[ stop_sound, _with_json(stop_output), _with_json(stop_input), stop_interpreter, stop_filter, ], callback=on_stop, hint='Stop channeling audio / other things ... '))) # ---------------------------------------------------------------------------------------------------------------------- # sh.prompt_until_exit()
def start() -> None: """Start prompting the user for input.""" # ---------------------------------------------------------------------------------------------------------------------- # sh.add_cmd( pcmd.Command('clear', 'cls', callback=pash.cmds.clear, hint='Clear the console ... ')) # ---------------------------------------------------------------------------------------------------------------------- # sh.add_cmd( pcmd.Command('exit', 'quit', callback=on_exit, hint='Quit the shell ... ')) # ---------------------------------------------------------------------------------------------------------------------- # get_user_cmd = pcmd.Command( 'user', 'u', callback=on_get_user, hint='Get, store and display a user\'s info ... ') get_user_cmd.add_arg('uname', type=str, help='Specify the username ... ') get_user_cmd.add_arg('-f', '--force-refresh', action='store_true', dest='force', help='Force reload info?') get_anss_cmd = pcmd.Command( 'answers', 'a', callback=on_get_answers, hint='Get and store all answers a user has ever given ... ') get_anss_cmd.add_arg('uname', type=str, help='Specify the username ... ') sh.add_cmd( pcmd.CascCommand('get', cmds=[ get_user_cmd, get_anss_cmd, ], hint='Get data from the API ... ')) # ---------------------------------------------------------------------------------------------------------------------- # ls_anss_cmd = pcmd.Command( 'answers', 'a', callback=on_ls_answers, hint='Get amount of answers stored in the db ... ') ls_anss_cmd.add_arg('-u', dest='uname', type=str, help='Specify a username ... ', required=False) sh.add_cmd( pcmd.CascCommand( 'ls', cmds=[ pcmd.Command( 'user', 'u', callback=on_ls_user, hint='Get and display all users stored in the db ... '), ls_anss_cmd, ], hint='List data from the db ... ')) # ---------------------------------------------------------------------------------------------------------------------- # find_cmd = pcmd.Command( 'find', 'query', callback=on_find, hint='Find all of a user\'s answers containing a substring ... ') find_cmd.add_arg('uname', type=str, help='Specify the username ... ') find_cmd.add_arg('substr', type=str, help='Specify the substring ... ') sh.add_cmd(find_cmd) # ---------------------------------------------------------------------------------------------------------------------- # sh.prompt_until_exit()