NOTE: notalawyer does not provide legal advice, and the developers of notalawyer will not be held responsible for any events that occur as a result of using notalawyer.
notalawyer embeds the license notices of your dependencies into your binary at build time and prints them at runtime behind a --license-notice flag. Licenses are gathered with cargo-about used as a library, so the cargo about binary does not need to be installed.
It comes in three crates:
notalawyer— theinclude_notice!macro that embeds the generated notice.notalawyer-clap— clap integration:ParseExt::parse_with_license_notice, which adds the--license-noticeflag (and re-exportsinclude_notice!).notalawyer-build— thebuild()helper to call frombuild.rs.
Add the crates (notalawyer-build is a build dependency):
$ cargo add notalawyer notalawyer-clap
$ cargo add --build notalawyer-buildabout.toml is cargo-about's configuration file — notalawyer uses it as-is. Add one next to Cargo.toml listing the accepted licenses:
# about.toml
accepted = ["Apache-2.0", "MIT", "Unicode-DFS-2016"]Call notalawyer_build::build() from build.rs:
// build.rs
fn main() {
notalawyer_build::build();
}Then parse your args with parse_with_license_notice instead of parse:
// src/main.rs
use clap::Parser;
use notalawyer_clap::*;
#[derive(Parser)]
struct Args { /* ... */ }
fn main() {
let args = Args::parse_with_license_notice(include_notice!());
}Running with --license-notice prints the notices and exits; otherwise parsing proceeds as usual. See the example/ directory for a complete, working setup.