fully replicate the commit.sh script as is

In fact, this script is missing some things we might like it to have
(e.g., making sure we're really in the right directory).
This commit is contained in:
Soren I. Bjornstad 2021-08-25 14:48:07 -05:00
parent 804e3bd05a
commit af147196e2
4 changed files with 25 additions and 7 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

0
filesystem.py Normal file
View File

5
git.py Normal file
View File

@ -0,0 +1,5 @@
import subprocess
from typing import Sequence
def exec(*args: Sequence[str]):
return subprocess.call(["git", *args])

26
tzk.py
View File

@ -1,27 +1,37 @@
from abc import ABC, abstractmethod, abstractclassmethod
import argparse
import os
import git
class CliCommand(ABC):
@abstractclassmethod
def setup_arguments(self, parser):
def setup_arguments(self, parser: argparse.ArgumentParser) -> None:
raise NotImplementedError
@abstractmethod
def execute(self, parser):
def execute(self, parser: argparse.ArgumentParser) -> None:
raise NotImplementedError
class CommitCommand(CliCommand):
cmd = "commit"
help = "Do a commit"
help = "Commit all changes to the wiki repository."
@classmethod
def setup_arguments(self, parser):
pass
def setup_arguments(self, parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"-m, --message",
metavar="MSG",
help="Commit message to use.",
default="daily checkpoint")
def execute(self, args):
print(f"We have committed!")
def execute(self, args: argparse.Namespace) -> None:
os.chdir("zk-wiki")
git.exec("add", "-A")
git.exec("commit", "-m", args.message)
git.exec("push", "backup")
parser = argparse.ArgumentParser()
@ -32,4 +42,6 @@ for command in CliCommand.__subclasses__():
command.setup_arguments(subparser)
args = parser.parse_args()
print(type(args))
9/0
args._cls().execute(args)