diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-10-30 02:24:12 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-10-30 02:24:12 +0800 |
| commit | 464313d02b76385d3a2e8809a4595afabca88dae (patch) | |
| tree | 6cbf81416b856ff15fdc4239de5e3624ef10b2cc /ricochet/scripts | |
| parent | cf58b3b4dfa0dbbd0ca492484ca241b320c4ba9e (diff) | |
| parent | bdefdb301db843e87aee8c6c35808d295bb66ee5 (diff) | |
| download | rcc-project-464313d02b76385d3a2e8809a4595afabca88dae.tar.gz rcc-project-464313d02b76385d3a2e8809a4595afabca88dae.tar.xz | |
Diffstat (limited to 'ricochet/scripts')
| -rw-r--r-- | ricochet/scripts/add_license.py | 57 | ||||
| -rw-r--r-- | ricochet/scripts/make-parallel.sh | 2 |
2 files changed, 59 insertions, 0 deletions
diff --git a/ricochet/scripts/add_license.py b/ricochet/scripts/add_license.py new file mode 100644 index 0000000..d15c1fc --- /dev/null +++ b/ricochet/scripts/add_license.py @@ -0,0 +1,57 @@ +import os +from pathlib import Path + +# File extensions to process +EXTENSIONS = {'.cpp', '.h', '.hpp', '.c', '.js', '.rs'} + +# License template +LICENSE_TEMPLATE = """/* + * Ricochet - A minimalist CLI web browser for fast, distraction-free navigation. + * Copyright (C) 2026 Richard Qin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +""" + +# Identifier to check if license already exists +IDENTIFIER = "Ricochet - A minimalist CLI web browser" + +def add_license_to_file(file_path): + try: + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + if IDENTIFIER in content[:500]: + print(f"[-] Skip: {file_path} (License already exists)") + return + with open(file_path, 'w', encoding='utf-8') as f: + f.write(LICENSE_TEMPLATE + "\n" + content) + print(f"[+] Updated: {file_path}") + + except Exception as e: + print(f"[!] Error: Failed to process {file_path} -> {e}") + +def main(target_dir): + path = Path(target_dir) + if not path.exists(): + print(f"Error: Path {target_dir} does not exist") + return + + for file in path.rglob('*'): + if file.suffix in EXTENSIONS: + add_license_to_file(file) + +if __name__ == "__main__": + project_root = input("Please enter the project root directory (press Enter to use the current directory): ").strip() or "." + main(project_root)
\ No newline at end of file diff --git a/ricochet/scripts/make-parallel.sh b/ricochet/scripts/make-parallel.sh new file mode 100644 index 0000000..879af9a --- /dev/null +++ b/ricochet/scripts/make-parallel.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec make -j`nproc` "$@" |
