Check the `X-Atomic-Min-Version` response header and warn if the current CLI version is older than the server's minimum requirement. Prints a warning to stderr when an upgrade is needed. Silently does nothing if the header is absent, unparseable, or already satisfied.
(headers: &HeaderMap)
| 36 | /// Prints a warning to stderr when an upgrade is needed. Silently does |
| 37 | /// nothing if the header is absent, unparseable, or already satisfied. |
| 38 | pub fn check_min_version_header(headers: &HeaderMap) { |
| 39 | let header_name = reqwest::header::HeaderName::from_static("x-atomic-min-version"); |
| 40 | |
| 41 | if let Some(val) = headers.get(&header_name) { |
| 42 | if let Ok(min_ver) = val.to_str() { |
| 43 | let current = crate::VERSION; |
| 44 | if needs_upgrade(current, min_ver) { |
| 45 | eprintln!( |
| 46 | "warning: this server requires Atomic CLI >= {} (you have {}). \ |
| 47 | Run 'atomic update' to upgrade.", |
| 48 | min_ver, current |
| 49 | ); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // ============================================================================ |
| 56 | // Tests |