my version of @dis.sociat.ing's dollcode algorithm in python
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

Switched to subcommands instead of flags, semver -> 1.0.0

- clearer cli
- removed print_dollcode as thats handled in main now
- updated README to reflect changes, fixed errors as well
- bumped semver -> 1.0.0 as dollcode is now feature complete (as of now)

digi 0949eb6e a9d587ee

+35 -28
+6 -6
README.md
··· 11 11 ``` 12 12 13 13 ## usage 14 - `uv run main.py <input>`: encodes input in dollcode 14 + `uv run main.py encode <input>`: encodes input in dollcode 15 15 ```sh 16 - uv run main.py "67" 16 + uv run main.py encode "67" 17 17 # outputs: ▖▘▌▘▘▌▘▌▖ 18 18 ``` 19 19 20 - `uv run main.py <input> -d`: converts input and copies output to clipboard 20 + `uv run main.py decode <input>`: decodes dollcode 21 21 ```sh 22 - uv run main.py "▌▘▌▖▘▘▘▘▘" -d 22 + uv run main.py decode "▌▘▌▖▘▘▘▘▘" 23 23 # outputs: hi 24 24 ``` 25 25 26 - `uv run main.py <input> -c`: copies output to clipboard 26 + `uv run main.py [encode/decode] <input> -c`: copies output to clipboard 27 27 ```sh 28 - uv run main.py "copy if pretty" -c 28 + uv run main.py encode "copy if pretty" -c 29 29 # outputs: ▖▌▌▖▌▖▌▘▌▖▖▘▘▘▘▌▌▖▖▌▌▘▖▖▘▖▌▖▘▘▌▖▖▖▖▌▖▘▘▘▌▖▖▖▘▘▌▖▌▘▘▖▌▖▘▘▌▖▌▖▘▘▌▌▖▖▖▌▖▘ -> 📋 copied! 30 30 ```
+27 -20
main.py
··· 60 60 return result 61 61 62 62 63 - # loops dollcode list, appends each output list entry to 64 - # string, then prints or prints + copies if appropriate flag was passed 65 - def print_dollcode(output: list[str], copy: bool): 66 - string: str = "" 63 + def main(command: str, input: str, copy: bool): 64 + result: str = "" 67 65 68 - for char in output: 69 - string += char 66 + if command == "decode": 67 + result = decode_base256_int(decode_dollcode(input)) 68 + else: 69 + encoded_dollcode = encode_dollcode(encode_base256_int(input)) 70 + result = "".join(encoded_dollcode) 70 71 71 72 if copy: 72 - pyperclip.copy(string) 73 - print(f"{string} -> 📋 copied!") 73 + pyperclip.copy(result) 74 + print(f"{result} -> 📋 copied!") 74 75 else: 75 - print(string) 76 + print(result) 76 77 77 78 78 - def main(input: str, copy: bool, decode: bool): 79 - if decode: 80 - print(decode_base256_int(decode_dollcode(input))) 81 - else: 82 - print_dollcode(encode_dollcode(encode_base256_int(input)), copy) 79 + if __name__ == "__main__": 80 + parser = argparse.ArgumentParser(description="converts input into dollcode") 81 + subparsers = parser.add_subparsers(dest="command", required=True) 82 + 83 + # encode subcommand 84 + encode_parser = subparsers.add_parser("encode", help="encode text to dollcode") 85 + encode_parser.add_argument("input", type=str, help="text to encode") 86 + encode_parser.add_argument( 87 + "-c", action="store_true", help="copy output to clipboard" 88 + ) 83 89 90 + # decode subcommand 91 + decode_parser = subparsers.add_parser("decode", help="decode dollcode to text") 92 + decode_parser.add_argument("input", type=str, help="dollcode to decode") 93 + decode_parser.add_argument( 94 + "-c", action="store_true", help="copy output to clipboard" 95 + ) 84 96 85 - if __name__ == "__main__": 86 - parser = argparse.ArgumentParser(description="converts input into dollcode") 87 - parser.add_argument("input", type=str, help="input to convert") 88 - parser.add_argument("-c", action="store_true", help="copy output to clipboard") 89 - parser.add_argument("-d", action="store_true", help="decode dollcode") 90 97 args = parser.parse_args() 91 - main(args.input, args.c, args.d) 98 + main(args.command, args.input, args.c)
+1 -1
pyproject.toml
··· 1 1 [project] 2 2 name = "dollcode" 3 - version = "0.4.0" 3 + version = "1.0.0" 4 4 description = "converts input into dollcode" 5 5 readme = "README.md" 6 6 requires-python = ">=3.13"
+1 -1
uv.lock
··· 4 4 5 5 [[package]] 6 6 name = "dollcode" 7 - version = "0.4.0" 7 + version = "1.0.0" 8 8 source = { virtual = "." } 9 9 dependencies = [ 10 10 { name = "pyperclip" },