Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tomodachi94 committed Oct 7, 2022
0 parents commit 048c897
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./tmp
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SignPic String Generator

A command-line interface for generating strings for use with the [SignPic mod](https://ftb.fandom.com/wiki/SignPic).

I made this because I was bored.

## Usage
### Windows

Download `signpic-generator.pyz` from the Releases page. Open command prompt and execute it with `python signpic-generator.pyz --help`.

## Linux (and Mac maybe?)

Download `signpic-generator` from the Releases page and execute with `signpic-generator --help`.
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env just --justfile

zipapp-build:
-mkdir ./tmp
python3 -m zipapp ./src --output ./tmp/signpic-generator.pyz
echo '#!/usr/bin/env python3' | cat - ./tmp/signpic-generator.pyz > ./tmp/signpic-generator
chmod +x ./tmp/signpic-generator
69 changes: 69 additions & 0 deletions src/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import argparse

parser = argparse.ArgumentParser(prog="signpic-generator",
description='Generate a string for the SignPic Minecraft mod.',
epilog="For more information on this string format, see https://ftb.fandom.com/wiki/SignPic.")

parser.add_argument('--url', "-u",
metavar='url',
type=str,
help='the URL of the image to show in the sign, including http:// or https://')

parser.add_argument('--image-width', "-iw",
metavar='width',
type=str,
help='the width of the image to display')

parser.add_argument('--image-height', "-ih",
metavar='width',
type=str,
help='the height of the image to display')

parser.add_argument('--width-offset', "-wo",
metavar='width',
type=str,
help='the width of the image offset')

parser.add_argument('--height-offset', '-ho',
metavar='width',
type=str,
help='the height of the image offset')

parser.add_argument('-v', '--vertical',
action='store_true',
help='change the orientation of the image to vertical')


def string_formatter(url: str,
image_width: str,
image_height: str,
width_offset: str,
height_offset: str,
vertical: str
):
if vertical:
vertical = "R"
else:
vertical = ""

if url.startswith("https://"):
secure = "$"
else:
secure = ""

url = url.replace("http://", "")
url = url.replace("https://", "")

return f"#{secure}{url}{{{image_width}x{image_height}, {width_offset}x{height_offset}{vertical}}}"


args = parser.parse_args()

print(string_formatter(
url=args.url,
image_width=args.image_width,
image_height=args.image_height,
width_offset=args.width_offset,
height_offset=args.height_offset,
vertical=args.vertical
))
Binary file added tmp/signpic-generator
Binary file not shown.
Binary file added tmp/signpic-generator.pyz
Binary file not shown.

0 comments on commit 048c897

Please sign in to comment.