https://github.com/unixorn/gitlike-commands
Easy python module for creating git-style subcommand handling.
https://github.com/unixorn/gitlike-commands
cli hacktoberfest python3
Last synced: 8 months ago
JSON representation
Easy python module for creating git-style subcommand handling.
- Host: GitHub
- URL: https://github.com/unixorn/gitlike-commands
- Owner: unixorn
- License: apache-2.0
- Created: 2022-03-09T14:59:39.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-02T14:29:41.000Z (over 1 year ago)
- Last Synced: 2024-10-18T13:16:24.313Z (about 1 year ago)
- Topics: cli, hacktoberfest, python3
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# gitlike-commands
[](https://opensource.org/license/apache-2-0/)
[](https://actions-badge.atrox.dev/unixorn/gitlike-commands/goto?ref=main)


[](https://codeclimate.com/github/unixorn/gitlike-commands)

## Background
`gitlike-commands` is a python module for easily creating `git`-style subcommand handling.
Refactored out of [thelogrus](https://github.com/unixorn/thelogrus/) so you don't have to import any modules that aren't part of the Python standard library.
## Usage
`subcommand_driver` automatically figures out what name the script was called as, then looks for subcommands and runs them if found, passing in any command line options.
So if you have a `foo` script in your `$PATH` as shown below
```python
#!/usr/bin/env python3
from gitlike_commands import subcommand_driver
if __name__ == '__main__':
subcommand_driver()
```
Running `foo bar baz` will look for a `foo-bar-baz` script, and if present in your `$PATH`, run it. If there is no `foo-bar-baz`, it will look for `foo-bar`, and if it finds that, run `foo-bar baz`.
If you're using poetry in your python project, you can add a gitlike driver as a scripts entry:
```toml
[tool.poetry.scripts]
gitalike-demo = "gitlike_commands:subcommand_driver"
```
The subcommands can be written in any language, the only requirements are that they are marked executable and follow the `foo-something` naming convention.