#!/usr/bin/env python3 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. """Continually runs a command and given arguemts Helpful for running commands that only differ in the last arg Use "exit", "quit", or "q" to exit program """ __all__ = ['main'] __author__ = "Cody A. Taylor ( codemister99@yahoo.com )" __version__ = "0.3.2" import sys from os import system def main(): if len(sys.argv) == 1 or "--help" in sys.argv[1:]: print("Usage: {} command [repeated_args]".format(sys.argv[0].split("/")[-1])) sys.exit() print('Use "!exit", "!quit", or "!q" to exit program', 'to add repeated arguments, start your args with @', 'to remove arguments, use !!N with N being the number of characters to remove', sep="\n") cmd = " ".join(sys.argv[1:]) while True: arg = input("{}: ".format(cmd)) if arg.strip().lower() in {"!exit", "!quit", "!q"}: sys.exit() if arg.startswith("@"): cmd += arg[1:] elif arg.startswith("!!"): try: amount = int(arg.strip()[2:]) except ValueError as err: print("Error:", err) else: cmd = cmd[:(len(cmd) - amount)] else: system("{} {}".format(cmd, arg)) if __name__ == "__main__": main()