Compare commits

..

No commits in common. "2d8c6320dc5c6e3ccb588d198dff887e34fbe3e6" and "4ebb93149061320291f1617ec8cbe85808d23ae0" have entirely different histories.

4 changed files with 15 additions and 26 deletions

View file

@ -1,5 +1,3 @@
"""Continuous Deployment."""
import os
from pathlib import Path
@ -73,19 +71,19 @@ def browse(root: str) -> None:
absolute_path = Path(directory) / file
relative_path = os.path.relpath(absolute_path, start=root)
paths.append(relative_path)
frame(root)
open(root)
for path in sorted(paths):
print(path)
shut(root)
def cat(file: str) -> None:
frame(file)
open(file)
print(fs.read_file_text(file).rstrip())
shut(file)
def install_commands(path: str) -> None:
def install_commands(path) -> None:
step("Install commands")
user = Path("/usr/local/bin")
for command in [
@ -96,10 +94,10 @@ def install_commands(path: str) -> None:
"synchronize",
]:
print(command)
(user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
os.symlink(path, user / f"{COMMANDS_PREFIX}{command}")
def set_ssh(*arguments: str) -> None:
def set_ssh(*arguments) -> None:
step("Set SSH")
#
ssh_key, ssh_hosts = arguments
@ -126,12 +124,12 @@ def set_ssh(*arguments: str) -> None:
cat(known)
def frame(*arguments: str) -> None:
def open(*arguments) -> None:
print(env.CD_OPEN, end="")
print(*arguments, flush=True)
def shut(*arguments: str) -> None:
def shut(*arguments) -> None:
print(env.CD_SHUT, end="")
print(*arguments, flush=True)
@ -140,7 +138,7 @@ def split() -> None:
print(env.CD_SPLT, flush=True)
def step(*arguments: str) -> None:
def step(*arguments) -> None:
env.CD_STEP += 1
print(env.CD_DOWN)
print(env.CD_VERT, env.CD_STEP, *arguments)

View file

@ -1,18 +1,17 @@
#! /usr/bin/env python3
"""Entry point to either bootstrap or command."""
import sys
from pathlib import Path
import cd
if __name__ == "__main__":
path, *arguments = sys.argv
name = Path(path).name
if name == "__main__.py":
command, *arguments = sys.argv
command = Path(command).name
if command == "__main__.py":
cd.set_ssh(*arguments)
cd.install_commands(__file__)
else:
function = getattr(cd, name.replace("-", "_"))
command = command.replace("-", "_")
function = getattr(cd, command)
function(*arguments)

View file

@ -1,10 +1,4 @@
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from cd.projects import Projects
BRANCH = [
"GITHUB_REF_NAME",
@ -21,7 +15,7 @@ ROOT = [
class Project:
def __init__(self: Project, projects: Projects) -> None:
def __init__(self, projects) -> None:
self.projects = projects
# branch
for variable in BRANCH:

View file

@ -1,5 +1,3 @@
from __future__ import annotations
from pathlib import Path
GROUP_AND_NAME = [
@ -13,7 +11,7 @@ SERVER_URL = [
class Projects:
def __init__(self: Projects, environment) -> None:
def __init__(self, environment) -> None:
self.environment = environment
# group, name
for variable in GROUP_AND_NAME: