]> Git repositories of Lucie Scarlet - gitignore.git/commitdiff
Initial commit
authorLucie Scarlet <lucie@scarlet.moe>
Thu, 4 Jul 2024 18:43:05 +0000 (20:43 +0200)
committerLucie Scarlet <lucie@scarlet.moe>
Thu, 4 Jul 2024 18:43:05 +0000 (20:43 +0200)
README.md [new file with mode: 0644]
gitignore [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..c495bfe
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+# gitignore
+
+Quick and dirty way to generate a gitignore file.
+Usage:
+`gitignore <langagues/frameworks/editors>`
+
+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 (executable)
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())