benthayer / git-gud

Wanna git gud? Then get git-gud, and git gud at git!
MIT License
401 stars 42 forks source link

`make_level.py` custom levels #272

Open benthayer opened 3 years ago

benthayer commented 3 years ago

A custom level looks something like this. It's not much different than a normal level, but they are used frequently for custom status messages and other things.

Having these automatically generated (as stubs) would help avoid confusion.

class Init(BasicLevel):
    def _setup(self):
        # Make sure we are not in a git repo
        file_operator = operations.get_operator()
        file_operator.destroy_repo()

    def post_setup(self):
        self.cat_file("post-setup.txt")

    def status(self):
        simulate_command("git status")

    def _test(self):
        # Check if we are in a git repo
        file_operator = operations.get_operator()
        return file_operator.repo_exists()

    def test_failed(self):
        default_fail_no_reset()

    def test_passed(self):
        self.cat_file("passed.txt")