def install_action(self): super().install_action() # Set up local config if platform == "darwin": git_credential = "osxkeychain" elif platform == "linux": git_credential = "cache" else: git_credential = "" git_authorname = click.prompt("git author name", err=True) git_authoremail = click.prompt("git author email", err=True) with Path.home().joinpath(".gitconfig.local").open("w+") as fd: fd.write( LOCAL_CONFIG_TEMPL.format( git_authorname=git_authorname, git_authoremail=git_authoremail, git_credential=git_credential, ) ) # Create SSH key if not already present. ssh_dir = Path.home() / ".ssh" id_rsa = ssh_dir / "id_rsa" id_rsa_pub = ssh_dir / "id_rsa.pub" if not id_rsa.exists(): shell.run(f"ssh-keygen -t rsa -b 4096 -C '{git_authoremail}' -f {id_rsa}") with id_rsa_pub.open() as fd: public_key = fd.read() output.message(f"Add your public key to GitHub:\n {public_key}") shell.run(f"ssh-add -K {id_rsa}")
def upgrade(ctx: click.Context, modules: Iterable[str], upgrade_all: bool): """ Upgrade modules. """ if upgrade_all: modules_to_upgrade = [ m for m in all_modules if config.is_module_installed(m.name) ] else: try: modules_to_upgrade = get_modules(modules) except ModuleNotFound as exc: output.error(str(exc)) raise click.Abort() error = False for module in modules_to_upgrade: try: output.message(f"Upgrading {module.name}...") module.upgrade() output.message(f"... {module.name} upgraded!") except (DependenciesMissing, NotInstalled, CalledProcessError) as exc: output.error(str(exc)) error = True if error: ctx.exit(1)
def upgrade_action(self): if sys.platform == "darwin": # There are issues with case-insensitive filenames that prevent the repo # from being pulled on macOS. output.message( "nerd-fonts cannot be upgraded on MacOS at the moment 😞") else: super().upgrade_action() for font_name in FONTS: shell.run(f"{self.repo_path / 'install.sh'} {font_name}")
def setup(root_dir: str): """ Install this tool and the basics. """ output.message("Installing qaz...") # Create config config.create_new_config_file(root_dir) # Create installed dir zshrc_dir = Path.home().joinpath(".zshrc.d") zshrc_dir.mkdir(exist_ok=True) ALREADY_INSTALLED = ("asdf", "python", "poetry") install(ALREADY_INSTALLED) output.message("... qaz is installed.")
def install(ctx: click.Context, modules: Tuple[str]): """ Install modules. """ try: modules_to_install = get_modules(modules) except ModuleNotFound as exc: output.error(str(exc)) raise click.Abort() error = False for module in modules_to_install: try: output.message(f"Installing {module.name}...") module.install() output.message(f"... {module.name} installed!") except (DependenciesMissing, CalledProcessError) as exc: output.error(str(exc)) error = True if error: ctx.exit(1)
def install_action(self): output.message("... this might take a while!") super().install_action() for font_name in FONTS: shell.run(f"{self.repo_path / 'install.sh'} {font_name}")