license_for_file/
license-for-file.rs1use debian_copyright::Copyright;
2use std::path::Path;
3
4pub const TEXT: &str = r#"Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
5Upstream-Author: John Doe <john@example>
6Upstream-Name: example
7Source: https://example.com/example
8
9Files: *
10License: GPL-3+
11Copyright: 2019 John Doe
12
13Files: debian/*
14License: GPL-3+
15Copyright: 2019 Jane Packager
16
17License: GPL-3+
18 This program is free software: you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by
20 the Free Software Foundation, either version 3 of the License, or
21 (at your option) any later version.
22"#;
23
24pub fn main() {
25 let c = TEXT.parse::<Copyright>().unwrap();
26 let license = c.find_license_for_file(Path::new("debian/foo")).unwrap();
27 println!("{}", license.name().unwrap());
28}