def __init__(self, stdinToArgs = True): lambdatools.setup(); self.stdin = []; self.args = sys.argv[1:]; self.switches = self.args.where(lambda a: a[0] == '-'); self.args = self.args.where(lambda a: a not in self.switches); if not sys.stdin.isatty(): for line in sys.stdin: if stdinToArgs: self.args.append(line.rstrip()); self.stdin.append(line.rstrip());
import sys, lambdatools def createShortcut(shortcut, target): global switches; if '-f' in switches: return '\n'.join([ '@echo off', 'cd /D {TARGET}' .replace('{TARGET}', target) ]); return '\n'.join([ '@echo off', 'if "%home%"=="" (cd /D %homedrive%%homepath%\{TARGET}) else (cd /D %home%\{TARGET})' .replace('{TARGET}', target) .replace('\\;', '') ]); if __name__ == "__main__": global switches; lambdatools.setup(); args = list(sys.argv[1:]); switches = args.where(lambda a: a[0] == '-'); args = args.where(lambda a: a not in switches); if len(args) > 1: with open('shortcuts\\' + args[0] + '.bat', 'w') as f: f.write(createShortcut(args[0], ' '.join(args[1:])));