dockershit

dockershit.docker

Docker Objects

class Docker()

run

def run(cmd)

Run a command in the Docker container

is_top_layer_empty

def is_top_layer_empty()

Check if top layer of Docker image is empty (0B)

dockershit.docker_file

For dealing with Dockerfiles

Dockerfile Objects

class Dockerfile()

parse_lines

def parse_lines(raw_lines: list[str]) -> list[str]

Parses multi-line commands into single lines

exists

def exists() -> bool

Returns True if the file exists

set_image

def set_image(image: str)

Sets the base image, in text. Example: “alpine:latest”

cd

def cd(pwd: str)

Set the working directory for the Dockerfile

remove_last_command

def remove_last_command(reason: str = "removed")

Actually comment it out then reload the file

save

def save()

Write the thing to a file

dockershit.command

Helpers for dealing with commands

split_command

def split_command(line: str) -> str

Get the command and args from a line

is_dockerfile

def is_dockerfile(line: str) -> bool

Case sensitive to avoid shell mismatches

is_simple

def is_simple(line: str) -> bool

Just a command with params; no operators, subshells, pipes, redirects or any of that fancy stuff.

is_hidden

def is_hidden(line: str) -> bool

If this line should be hidden

matters

def matters(line: str) -> bool

Does this line even do anything?

flatten

def flatten(lines: str) -> str

Flatten a multi-line command into a single line

dockershit.keyboard

Keyboard Objects

class Keyboard()

input

def input()

Get input from the user, with multi-line continuation via backslash.

dockershit.dockershit

parse_args

def parse_args(argv: list[str] = sys.argv[1:])

Nobody likes an argument, but sometimes you just have to parse them.

run

def run(path: str, image: str, shell: str, tag: str, debug: bool)

The input loop.

main

def main(argv: str = sys.argv[1:])

The main course.