mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Display legacy config file warning when 2.x config file found
This commit is contained in:
@@ -9,6 +9,8 @@ use reqwest::Url;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::status;
|
||||||
|
|
||||||
const DEFAULT_SERVER_URL: &str = "https://asciinema.org";
|
const DEFAULT_SERVER_URL: &str = "https://asciinema.org";
|
||||||
const INSTALL_ID_FILENAME: &str = "install-id";
|
const INSTALL_ID_FILENAME: &str = "install-id";
|
||||||
|
|
||||||
@@ -202,10 +204,14 @@ fn save_install_id(path: &PathBuf, id: &str) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn user_config_path() -> Result<PathBuf> {
|
pub fn user_config_path() -> Result<PathBuf> {
|
||||||
Ok(home()?.join("config.toml"))
|
Ok(home()?.join("config.toml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn legacy_user_config_path() -> Result<PathBuf> {
|
||||||
|
Ok(home()?.join("config"))
|
||||||
|
}
|
||||||
|
|
||||||
fn user_defaults_path() -> Result<PathBuf> {
|
fn user_defaults_path() -> Result<PathBuf> {
|
||||||
Ok(home()?.join("defaults.toml"))
|
Ok(home()?.join("defaults.toml"))
|
||||||
}
|
}
|
||||||
@@ -260,3 +266,27 @@ fn parse_key<S: AsRef<str>>(key: S) -> Result<Key> {
|
|||||||
|
|
||||||
Err(anyhow!("invalid key definition '{key}'"))
|
Err(anyhow!("invalid key definition '{key}'"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn check_legacy_config_file() {
|
||||||
|
let Ok(legacy_path) = legacy_user_config_path() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(new_path) = user_config_path() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if legacy_path.exists() {
|
||||||
|
status::warning!(
|
||||||
|
"Your config file at {} uses the location and format from asciinema 2.x.",
|
||||||
|
legacy_path.to_string_lossy()
|
||||||
|
);
|
||||||
|
|
||||||
|
status::warning!(
|
||||||
|
"For asciinema 3.x (this version) create a new config file at {}.",
|
||||||
|
new_path.to_string_lossy()
|
||||||
|
);
|
||||||
|
|
||||||
|
status::warning!("Read the documentation (CLI -> Configuration) for details.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
|
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
|
||||||
|
|
||||||
|
crate::config::check_legacy_config_file();
|
||||||
|
|
||||||
match cli.command {
|
match cli.command {
|
||||||
Commands::Rec(cmd) => {
|
Commands::Rec(cmd) => {
|
||||||
let cmd = Session {
|
let cmd = Session {
|
||||||
|
|||||||
Reference in New Issue
Block a user