Skip to content

Commit

Permalink
docs(README): fix example and add print
Browse files Browse the repository at this point in the history
Add section for installing dependency with cargo.
  • Loading branch information
WyvernIXTL committed Sep 13, 2024
1 parent 87a8929 commit 161da79
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,35 @@ Licenses are retrieved by searching in the following order:
* Text from `spdx` with identifier in `Cargo.toml`

## Usage
### *Cargo*

```
cargo add license-retriever
cargo add --build license-retriever
```

### `build.rs`

```rust
// build.rs ==========
fn main() {
let config = license_retriever::Config {
// options...
..Config::default()
};
license_retriever::LicenseRetriever::from_config(&config)?.save_in_out_dir("licenses")?;
}

// main project ==========
fn main() {
let licenses = license_retriever::license_retriever_data!("licenses").unwrap(); // Vec<(Package, Vec<String>)>
}
use license_retriever::{Config, LicenseRetriever};

fn main() {
let config = Config {
// options...
..Config::default()
};
LicenseRetriever::from_config(&config).unwrap().save_in_out_dir("LICENSE-3RD-PARTY").unwrap();
}

```

### `main.rs`

```rust
use license_retriever;

fn main() {
let licenses = license_retriever::license_retriever_data!("LICENSE-3RD-PARTY").unwrap();
println!("{}", licenses);
}
```

0 comments on commit 161da79

Please sign in to comment.