tyki6 / rawsec_cli

Rawsec's Cybersecurity Inventory cli. Search pentesting tools, resources, ctf, os.
https://inventory.raw.pm
MIT License
24 stars 6 forks source link

help & version option #20

Closed noraj closed 3 years ago

noraj commented 3 years ago

If it's possible to have -h option alias for --help and also maybe add a -V and --version that display the version (1.0.0) and the build commit (eg. 442239e).

tyki6 commented 3 years ago

rawsec-cli --version output:

rawsec-cli, version: 1.0.0, commit: b016aca28c20f6b64d5a4eb84e226fc2a35ed472
Full documentation: https://rawsec-cli.readthedocs.io/

Can you check my code?

in setup.py when you run python setup.py install i write build commit in a file. I don't know if you have a better idea, if not i will merged and close issue.

try:
    commit = subprocess.check_output("git rev-parse --verify HEAD", shell=True)
except subprocess.CalledProcessError as e:
    print("Exception on process, rc=", e.returncode, "output=", e.output)
    commit = b"commit name not found"

with open("rawsec_cli/__init__.py", "w") as f:
    f.write(
        f'# autogenerated\n__version__ = "{str(version)}"\n__commit__ = "{str(commit, "utf-8").strip()}"\n',
    )
f.close()
noraj commented 3 years ago

Looks good, I don't see another way writing the build id in a file.

tyki6 commented 3 years ago

ok lets go so.