def parse_arguments(): # noqa if platform.system() == 'Windows': default_user_destdir = os.path.join( os.getenv('LOCALAPPDATA', ''), 'autojump', ) else: default_user_destdir = os.path.join( os.path.expanduser('~'), '.autojump', ) default_user_prefix = '' default_user_zshshare = 'functions' default_system_destdir = '/' default_system_prefix = '/usr/local' default_system_zshshare = '/usr/share/zsh/site-functions' default_clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink') parser = ArgumentParser( description='Installs autojump globally for root users, otherwise \ installs in current user\'s home directory.' ) parser.add_argument( '-n', '--dryrun', action='store_true', default=False, help='simulate installation', ) parser.add_argument( '-f', '--force', action='store_true', default=False, help='skip root user, shell type, Python version checks', ) parser.add_argument( '-d', '--destdir', metavar='DIR', default=default_user_destdir, help='set destination to DIR', ) parser.add_argument( '-p', '--prefix', metavar='DIR', default=default_user_prefix, help='set prefix to DIR', ) parser.add_argument( '-z', '--zshshare', metavar='DIR', default=default_user_zshshare, help='set zsh share destination to DIR', ) parser.add_argument( '-c', '--clinkdir', metavar='DIR', default=default_clink_dir, help='set clink directory location to DIR (Windows only)', ) parser.add_argument( '-s', '--system', action='store_true', default=False, help='install system wide for all users', ) args = parser.parse_args() if not args.force: if sys.version_info[0] == 2 and sys.version_info[1] < 6: print('Python v2.6+ or v3.0+ required.', file=sys.stderr) sys.exit(1) if args.system: if platform.system() == 'Windows': print( 'System-wide installation is not supported on Windows.', file=sys.stderr, ) sys.exit(1) elif os.geteuid() != 0: print( 'Please rerun as root for system-wide installation.', file=sys.stderr, ) sys.exit(1) if platform.system() != 'Windows' \ and get_shell() not in SUPPORTED_SHELLS: print( 'Unsupported shell: %s' % os.getenv('SHELL'), file=sys.stderr, ) sys.exit(1) if args.destdir != default_user_destdir \ or args.prefix != default_user_prefix \ or args.zshshare != default_user_zshshare: args.custom_install = True else: args.custom_install = False if args.system: if args.custom_install: print( 'Custom paths incompatible with --system option.', file=sys.stderr, ) sys.exit(1) args.destdir = default_system_destdir args.prefix = default_system_prefix args.zshshare = default_system_zshshare return args
def parse_arguments(): default_clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink') parser = ArgumentParser( description='Uninstalls autojump.') parser.add_argument( '-n', '--dryrun', action="store_true", default=False, help='simulate installation') parser.add_argument( '-u', '--userdata', action="store_true", default=False, help='delete user data') parser.add_argument( '-d', '--destdir', metavar='DIR', help='custom destdir') parser.add_argument( '-p', '--prefix', metavar='DIR', default='', help='custom prefix') parser.add_argument( '-z', '--zshshare', metavar='DIR', default='functions', help='custom zshshare') parser.add_argument( '-c', '--clinkdir', metavar='DIR', default=default_clink_dir) return parser.parse_args()
def parse_arguments(): # noqa if platform.system() == 'Windows': default_user_destdir = os.path.join( os.getenv('LOCALAPPDATA', ''), 'autojump') else: default_user_destdir = os.path.join( os.path.expanduser("~"), '.autojump') default_user_prefix = '' default_user_zshshare = 'functions' default_system_destdir = '/' default_system_prefix = '/usr/local' default_system_zshshare = '/usr/share/zsh/site-functions' default_clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink') parser = ArgumentParser( description='Installs autojump globally for root users, otherwise \ installs in current user\'s home directory.') parser.add_argument( '-n', '--dryrun', action="store_true", default=False, help='simulate installation') parser.add_argument( '-f', '--force', action="store_true", default=False, help='skip root user, shell type, Python version checks') parser.add_argument( '-d', '--destdir', metavar='DIR', default=default_user_destdir, help='set destination to DIR') parser.add_argument( '-p', '--prefix', metavar='DIR', default=default_user_prefix, help='set prefix to DIR') parser.add_argument( '-z', '--zshshare', metavar='DIR', default=default_user_zshshare, help='set zsh share destination to DIR') parser.add_argument( '-c', '--clinkdir', metavar='DIR', default=default_clink_dir, help='set clink directory location to DIR (Windows only)') parser.add_argument( '-s', '--system', action="store_true", default=False, help='install system wide for all users') args = parser.parse_args() if not args.force: if sys.version_info[0] == 2 and sys.version_info[1] < 6: print("Python v2.6+ or v3.0+ required.", file=sys.stderr) sys.exit(1) if args.system: if platform.system() == 'Windows': print("System-wide installation is not supported on Windows.", file=sys.stderr) sys.exit(1) elif os.geteuid() != 0: print("Please rerun as root for system-wide installation.", file=sys.stderr) sys.exit(1) if platform.system() != 'Windows' \ and get_shell() not in SUPPORTED_SHELLS: print("Unsupported shell: %s" % os.getenv('SHELL'), file=sys.stderr) sys.exit(1) if args.destdir != default_user_destdir \ or args.prefix != default_user_prefix \ or args.zshshare != default_user_zshshare: args.custom_install = True else: args.custom_install = False if args.system: if args.custom_install: print("Custom paths incompatible with --system option.", file=sys.stderr) sys.exit(1) args.destdir = default_system_destdir args.prefix = default_system_prefix args.zshshare = default_system_zshshare return args
def parse_arguments(): default_clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink') parser = ArgumentParser(description='Uninstalls autojump.') parser.add_argument('-n', '--dryrun', action="store_true", default=False, help='simulate installation') parser.add_argument('-u', '--userdata', action="store_true", default=False, help='delete user data') parser.add_argument('-d', '--destdir', metavar='DIR', help='custom destdir') parser.add_argument('-p', '--prefix', metavar='DIR', default='', help='custom prefix') parser.add_argument('-z', '--zshshare', metavar='DIR', default='functions', help='custom zshshare') parser.add_argument('-c', '--clinkdir', metavar='DIR', default=default_clink_dir) return parser.parse_args()
def parse_arguments(): # noqa if platform.system() == "Windows": default_user_destdir = os.path.join(os.getenv("LOCALAPPDATA", ""), "autojump") else: default_user_destdir = os.path.join(os.path.expanduser("~"), ".autojump") default_user_prefix = "" default_user_zshshare = "functions" default_system_destdir = "/" default_system_prefix = "/usr/local" default_system_zshshare = "/usr/share/zsh/site-functions" default_clink_dir = os.path.join(os.getenv("LOCALAPPDATA", ""), "clink") parser = ArgumentParser( description="Installs autojump globally for root users, otherwise \ installs in current user's home directory." ) parser.add_argument("-n", "--dryrun", action="store_true", default=False, help="simulate installation") parser.add_argument( "-f", "--force", action="store_true", default=False, help="skip root user, shell type, Python version checks" ) parser.add_argument("-d", "--destdir", metavar="DIR", default=default_user_destdir, help="set destination to DIR") parser.add_argument("-p", "--prefix", metavar="DIR", default=default_user_prefix, help="set prefix to DIR") parser.add_argument( "-z", "--zshshare", metavar="DIR", default=default_user_zshshare, help="set zsh share destination to DIR" ) parser.add_argument( "-c", "--clinkdir", metavar="DIR", default=default_clink_dir, help="set clink directory location to DIR (Windows only)", ) parser.add_argument("-s", "--system", action="store_true", default=False, help="install system wide for all users") args = parser.parse_args() if not args.force: if sys.version_info[0] == 2 and sys.version_info[1] < 6: print("Python v2.6+ or v3.0+ required.", file=sys.stderr) sys.exit(1) if args.system: if platform.system() == "Windows": print("System-wide installation is not supported on Windows.", file=sys.stderr) sys.exit(1) elif os.geteuid() != 0: print("Please rerun as root for system-wide installation.", file=sys.stderr) sys.exit(1) if platform.system() != "Windows" and get_shell() not in SUPPORTED_SHELLS: print("Unsupported shell: %s" % os.getenv("SHELL"), file=sys.stderr) sys.exit(1) if ( args.destdir != default_user_destdir or args.prefix != default_user_prefix or args.zshshare != default_user_zshshare ): args.custom_install = True else: args.custom_install = False if args.system: if args.custom_install: print("Custom paths incompatible with --system option.", file=sys.stderr) sys.exit(1) args.destdir = default_system_destdir args.prefix = default_system_prefix args.zshshare = default_system_zshshare return args
def parse_arguments(): parser = ArgumentParser( description='Uninstalls autojump.') parser.add_argument( '-n', '--dryrun', action="store_true", default=False, help='simulate installation') parser.add_argument( '-u', '--userdata', action="store_true", default=False, help='delete user data') parser.add_argument( '-d', '--destdir', metavar='DIR', help='custom destdir') parser.add_argument( '-p', '--prefix', metavar='DIR', default='', help='custom prefix') parser.add_argument( '-z', '--zshshare', metavar='DIR', default='functions', help='custom zshshare') return parser.parse_args()