r/coolgithubprojects • • 4d ago

Mkcmd an easy way to make personal projects into executable commands

https://github.com/jacobrinaldi/mkcmd
2 Upvotes

10 comments sorted by

1

u/kantorcodes1 4d ago

Having it installed into /usr/local/bin in the form of just one main.py makes it ridiculously easy. After making a script into a command, what do you need to do to have it use the updated script after you edit it?

1

u/LNXByte 4d ago

im not sure what you mean? Sorry im new to programing. But from my understanding i believe you would have to remove the command and remake set it up.

1

u/kantorcodes1 4d ago

Alright, let me see if I can make this even clearer. I create a command out of one of my scripts. Then I go back and change something about that script. Do I need to run it back through mkcmd so that it uses the changes that I made to the script to make the command?

1

u/LNXByte 4d ago

Yes you would have to run thru mkcmd again. Since i am currently not sure how to make it function without rerunning

1

u/kantorcodes1 4d ago

That rerun makes sense for now. I help run HOL Guard, a firewall for AI agents. Guard checks a command before an agent runs it. mkcmd fits Guard's command extensions. Your file would be contributions/command-sources/command.mkcmd.json. The merged command.xcomm.json shows the shape. First test: a fixture with one normal installation of your own script. Would you open that PR?

Guide: https://github.com/hashgraph-online/hol-guard/blob/main/docs/guard/extensions/contributing.md

1

u/LNXByte 4d ago edited 4d ago

If by PR you mean pull request or something of the likes then yes i would be open to that. If you do mean pull request would i be credited for mkcmd? Very sorry if this is some stupid confusion.

1

u/kantorcodes1 4d ago

Yes, pull request. And nothing to apologise for, it is a fair question.

You would be credited. The PR goes in from your own GitHub account with your name on it as the author, and mkcmd stays your project. All you add is one file: contributions/command-sources/command.mkcmd.json. The merged command.xcomm.json sits in the same folder and shows the shape to copy. For the first test, a fixture with one normal installation of one of your own scripts is enough.

Shout here if a step in the guide trips you up, and I will walk through it with you.

Guide: https://github.com/hashgraph-online/hol-guard/blob/main/docs/guard/extensions/contributing.md

1

u/LNXByte 3d ago

How do i make the .json and also what are those uv run commands?

1

u/kantorcodes1 3d ago

Good questions, both of them. You are not writing the .json from nothing, you copy a file that is already merged in the contributions/command-sources folder of your fork, rename the copy to command.mkcmd.json, and change the name, the short description and the executable at the top so they say mkcmd. The copy itself shows you what a finished one looks like.

uv is a small program that runs a project's own scripts for you. The two lines from the guide go in a terminal inside your fork folder after the file is saved: the first checks your file against a small example and builds the public record for the PR, and the second runs a final check. Neither line touches mkcmd itself.

uv run --no-sync python scripts/prepare_extension_contribution.py --source contributions/command-sources/command.mkcmd.json --fixture tests/fixtures/command-source-mkcmd.v1.json

uv run --no-sync hol-guard extensions handoff --repo . --source contributions/command-sources/command.mkcmd.json --fixture tests/fixtures/command-source-mkcmd.v1.json

One more small file goes with it, tests/fixtures/command-source-mkcmd.v1.json, holding one normal mkcmd install as the example. Start with the copy and the rename, that part is shorter than it looks.

Guide: https://github.com/hashgraph-online/hol-guard/blob/main/docs/guard/extensions/contributing.md

1

u/LNXByte 3d ago

What's a fork folder? Sorry I've never done any PRs