forked from cloudposse-archives/copyright-header
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.yaml
221 lines (180 loc) · 7.89 KB
/
README.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#
# Name of this project
name: copyright-header
# Logo for this project
#logo: docs/logo.png
# License of this project
license: "GPL3"
# Canonical GitHub repo
github_repo: cloudposse/copyright-header
# Badges to display
badges:
- name: "Build Status"
image: "https://travis-ci.org/cloudposse/copyright-header.svg?branch=master"
url: "https://travis-ci.org/cloudposse/copyright-header"
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/copyright-header.svg"
url: "https://github.com/cloudposse/copyright-header/releases"
- name: "Slack Community"
image: "https://slack.cloudposse.com/badge.svg"
url: "https://slack.cloudposse.com"
# Short description of this project
description: |-
Copyright Header is a utility to manipulate licenses on source code.
Features
--------
* Add/remove a copyright headers recursively on source files
* Customize the syntax configuration for how to write out comments
* Built-in support for GPL3 and MIT licenses
* Supports custom licenes with `--license-file` argument
* ERB template support
Caveats
-------
* Will only remove headers to files that have exactly the same header as the one we added
* Will only add headers to files which do not contain the case-sensitive pattern `/[Cc]opyright|[Lc]icense/` in the first `N` lines
* Will not properly format arguments that contain new-line ("`\n`") characters.
Requirements
------------
* Ruby 1.9.2 (supported version, might work with older rubies but not guaranteed)
Installation
------------
Install Copyright Header from RubyForge:
gem install copyright-header
# How to use this project
usage: |-
Full list of supported arguments:
Usage: copyright-header options [file]
-n, --dry-run Output the parsed files to STDOUT
-o, --output-dir DIR Use DIR as output directory
--license-file FILE Use FILE as header (instead of using --license argument)
--license [AGPL3|ASL2|BSD-2-CLAUSE|BSD-3-CLAUSE|BSD-4-CLAUSE|GPL3|MIT]
Use LICENSE as header
--copyright-software NAME The common name for this piece of software (e.g. "Copyright Header")
--copyright-software-description DESC
The detailed description for this piece of software (e.g. "A utility to manipulate copyright headers on source code files")
--copyright-holder NAME The legal owner of the copyright for the software. (e.g. "Erik Osterman <e@osterman.com>"). Repeat argument for multiple names.
--copyright-year YEAR The years for which the copyright exists (e.g. "2012-2017"). Repeat argument for multiple years.
-w, --word-wrap LEN Maximum number of characters per line for license (default: 80)
-a, --add-path PATH Recursively insert header in all files found in path (allows multiple paths separated by platform path-separator ":")
-r, --remove-path PATH Recursively remove header in all files found in path (allows multiple paths separated by platform path-separator ":")
-g, --guess-extension Use the GitHub Linguist gem to guess the extension of the source code when no extension can be determined (experimental).
-c, --syntax FILE Syntax configuration file
-V, --version Display version information
-h, --help Display this screen
# Example usage
examples: |-
Discover available parameters by passing the `--help` argument
copyright-header --help
Add a GPL3 License header to a file:
copyright-header --add-path /tmp/test.rb \
--license GPL3 \
--copyright-holder 'Joe Shmoe' \
--copyright-software 'Example Software' \
--copyright-software-description "This is the description of the software." \
--copyright-year 2012-2017 \
--output-dir /tmp \
--dry-run
Remove the header created in the previous step (without --dry-run argument):
copyright-header --remove-path /tmp/test.rb \
--license GPL3 \
--copyright-holder 'Joe Shmoe' \
--copyright-software 'Example Software' \
--copyright-software-description 'This is the description of the software.' \
--copyright-year 2012-2017 \
--output-dir /tmp \
--dry-run
Command used to generate copyright headers for this script:
copyright-header --license GPL3 \
--add-path lib/:bin/ \
--guess-extension \
--copyright-holder 'Erik Osterman <e@osterman.com>' \
--copyright-software 'Copyright Header' \
--copyright-software-description "A utility to manipulate copyright headers on source code files" \
--copyright-year 2012-2017 \
--word-wrap 100 \
--output-dir ./
Paths can be either files or directories. It will recursively traverse the directory tree ignoring all dot files.
You can specify an alternative syntax configuration file using the `--syntax` argument.
## Rake
The above example can be performed as rake task inside a Rakefile:
task :headers do
require 'rubygems'
require 'copyright_header'
args = {
:license => 'GPL3',
:copyright_software => 'Copyright Header',
:copyright_software_description => "A utility to manipulate copyright headers on source code files",
:copyright_holders => ['Erik Osterman <e@osterman.com>'],
:copyright_years => ['2012-2017'],
:add_path => 'lib',
:output_dir => '.'
}
command_line = CopyrightHeader::CommandLine.new( args )
command_line.execute
end
## Docker
```
docker run --rm --volume `pwd`:/usr/src/ osterman/copyright-header:latest \
--license GPL3 \
--add-path . \
--guess-extension \
--copyright-holder 'Erik Osteman <e@osterman.com>' \
--copyright-software 'Copyright Header' \
--copyright-software-description 'A utility to manipulate copyright headers on source code files' \
--copyright-year 2012-2017 \
--word-wrap 100 \
--output-dir /usr/src/
```
## Make
Here is how we typically use it in our [`Makefile`](Makefile).
Check out the Cloud Posse [`build-harness`](https://github.com/cloudposse/build-harness/) for other neat tricks.
# Example goes here...
# How to get started quickly
#quickstart: |-
# Here's how to get started...
# Contributors to this project
contributors:
- name: "Erik Osterman"
github: "osterman"
- name: "Leo O'Donnell"
github: "leopoldodonnell"
- name: "Christian Meier"
github: "mkristian"
- name: "Gabriel de Perthuis"
github: "g2p"
- name: "Thomas Russell Murphy"
github: "thomasrussellmurphy"
- name: "Kongqun Yang"
github: "kqyang"
- name: "Vincent Billey"
github: "Fenntasy"
- name: "arximboldi"
github: "arximboldi"
- name: "David"
github: "TAGC"
- name: "Rafał Rzepecki"
github: "dividedmind"
- name: "David Yip"
github: "yipdw"
- name: "Daniel Freedman"
github: "azakus"
- name: "Mitch Souders"
github: "crzysdrs"
- name: "Mads Bondo Dydensborg"
github: "mbd-dbc-dk"
- name: "Psy-Q"
github: "psy-q"
- name: "Bryan"
github: "bstopp"
- name: "Colin Dean"
github: "colindean"
- name: "Wahaj Shamim"
github: "wshamim"
- name: "halo"
github: "halo"
- name: "Lloyd Dewolf"
github: "lloydde"