1use rustify_licensing::adapters::headless::check_blocking;
13use rustify_licensing::{KeygenProvider, LicenseConfig, LicenseState, StorageConfig};
14
15fn main() {
16 let storage = StorageConfig {
17 path: std::env::temp_dir().join("rustify-demo-license.env"),
18 dev_shadow: None,
19 env_key_var: Some("RUSTIFY_DEMO_KEY".into()),
20 };
21 let config = LicenseConfig {
22 account_id: std::env::var("KEYGEN_ACCOUNT")
24 .unwrap_or_else(|_| "YOUR_KEYGEN_ACCOUNT_ID".into()),
25 api_base: "https://api.keygen.sh/v1".into(),
26 grace_secs: 14 * 24 * 60 * 60,
27 storage,
28 buy_url: "https://example.com/#pricing".into(),
29 };
30
31 let provider = KeygenProvider::from_config(&config);
32 let mut state = LicenseState::load(&config.storage);
33 println!("fingerprint: {}", state.fingerprint);
34
35 if state.key.trim().is_empty() {
36 println!("no key set — export RUSTIFY_DEMO_KEY=<license-key> to test → status: Locked");
37 return;
38 }
39
40 let status = check_blocking(&config, &provider, &mut state, |line| println!(" … {line}"));
41 println!("status: {status:?}");
42}