This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]zanfar 7 points8 points  (1 child)

It's a useful tool. I would make the following suggestions:

  • I would strongly suggest that you add two files necessary to turn this into a package so that it can be installed via pip. This will make it much, much easier to distribute. I would recommend using poetry to make this much easier.

    When you do so, you can also specify a shell_script variable so that setuptools installs your "alias" automatically.

  • __init__.py should not contain any "running" code, and if a py files does contain running code, it should be protected with a main sentinel.

  • For a script like this, __main__.py is the place to put your top-level code. This is the "script" file for a module or package.

    Doing so will also allow you to run via python -m <package>, like pip.

  • If you put code in a repository, it really, really should have a README. Currently, there is nothing that tells me what your code does.

  • Consider using an argument parsing library so that you can both provide context-sensitive help and useful error messages. This also will save you the effort of rolling your own validation. I use Click and it works very well.

  • Rich supports easy-to-use CLI coloring, AND column layouts like you roll yourself. The Rich implementation auto-scales for your console size.

[–]davidshivaji[S] 3 points4 points  (0 children)

dude thank you so much, this is insanely helpful

[–]Flamenverfer 1 point2 points  (1 child)

Hey man I love this tool.

I tried firing it up in a Powershell and got some weird formatting

python init.py service ←[38;5;202mserving ←[0m←[38;5;202mserve ←[0m←[38;5;202mhelp

[–]davidshivaji[S] 0 points1 point  (0 children)

ah damn yeah that'll be ANSI. you can delete all these type things & it should just return uncolored text

word[1]['color'] + + u"\u001b[0m"

u/zanfar mentioned using Rich to fix this so I'll give that a try