From: Lucie Scarlet Date: Thu, 4 Jul 2024 18:43:05 +0000 (+0200) Subject: Initial commit X-Git-Url: https://git.chaotic.ninja/gitweb/lucie/?a=commitdiff_plain;h=ae9d4f612150653638d06d4c4edf594dbbe26050;p=gitignore.git Initial commit --- ae9d4f612150653638d06d4c4edf594dbbe26050 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c495bfe --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# gitignore + +Quick and dirty way to generate a gitignore file. +Usage: +`gitignore ` + +You can either comma-separate this or space-separate this. You will be asked to save the file (to .gitignore in the current folder) or just view it. + +I recommend viewing it first and double checking if it's all good before running it again and saving. + +It includes gitignore values for Vim by default as this is the default editor I use. For CMake projects it also includes the folder `build/` as this is standard for my programming, and is not included by default from gitignore.io. diff --git a/gitignore b/gitignore new file mode 100755 index 0000000..b0a5d98 --- /dev/null +++ b/gitignore @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import requests +from sys import argv + +GITIGNORE_BASE_URL = "https://www.toptal.com/developers/gitignore/api/vim" + +def main() -> int: + FINAL_URL: str = GITIGNORE_BASE_URL + gitignore: str = "" + for arg in argv[1:]: + FINAL_URL += f",{arg.lower()}" + res: requests.Response = requests.get(FINAL_URL) + gitignore = res.text + print(gitignore) + to_save: str = input("Gitignore file has been generated. Save? (Y/n) ") + if "cmake" in argv: + gitignore += "\nbuild/" + if to_save.lower() == "y" or to_save == "" or to_save.lower() == "yes": + save_file(gitignore) + return 0 + +def save_file(contents: str) -> None: + with open("./.gitignore", "w") as g: + g.write(contents) + print("Wrote contents to `.gitignore`.") + +if __name__ == "__main__": + raise SystemExit(main())