Copy License
Copies software licenses into your project. Optionally, it also adds the short variant of the license into your main file.
Usage
Create license in directory
./cp-license.py [license short name] [destination directory] [author] [date]
Consult the help menu for all options and more information:
./cp-license.py h
Add license into your file
./cp-license pre [license short name] [author] [date] [language] [source file]
More information about the prepend-mode:
./cp-license.py h pre
Examples
Add a license to your project:
./cp-license.py mit ~/foo/bar/my_project_dir
Some licenses have a "author" & "year" placeholder. You can populate them directly:
./cp-license.py mit ~/foo/bar/my_project_dir Peter 2025
You can omit the date 2025 and it will use the current year.
Add a short variant of the license into your main file:
./cp-license.py pre gpl3 Peter 2025 c src/main.c
If you replace 2025 with 0, it will use the current year.
You can also omit the author and date:
./cp-license.py pre gpl3 c src/main.c
Notes on pre, prepend
- it will always create a backup of your file, before writing into it.
- if a backup exists, it does not overwrite the backup
- if a shebang
#!and/or editor mode-*-exists, it will append the license text below it
Add a new license
Please consult cp-license.py and look for the docstring # How to add a new license.
Add a new language comment token
Consult cp-license.py and look for # How to add a new language comment token