refact(config)!: use toml instead of yaml
serde_yaml is deprecated and archived. We should not depend on that. Therefore switching to toml. Fixes #76.
This commit is contained in:
@@ -23,7 +23,7 @@ enum_dispatch = "0.3"
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_yaml = "0.9"
|
||||
toml = "0.4"
|
||||
|
||||
# backends
|
||||
alpm = { version = "3.0", optional = true }
|
||||
|
||||
@@ -6,7 +6,7 @@ use anyhow::{bail, Context, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// Update the master README if fields change.
|
||||
/// Config for the program, as listed in `$XDG_CONFIG_HOME/pacdef/pacdef.yaml`.
|
||||
/// Config for the program, as listed in `$XDG_CONFIG_HOME/pacdef/pacdef.toml`.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Config {
|
||||
/// The AUR helper to use for Arch Linux.
|
||||
@@ -61,7 +61,7 @@ impl Config {
|
||||
}
|
||||
};
|
||||
|
||||
serde_yaml::from_str(&content).context("parsing yaml config")
|
||||
toml::from_str(&content).context("parsing toml config")
|
||||
}
|
||||
|
||||
/// Save the instance of [`Config`] to disk.
|
||||
@@ -70,7 +70,7 @@ impl Config {
|
||||
///
|
||||
/// This function will return an error if the config file cannot be saved to disk.
|
||||
pub fn save(&self, file: &Path) -> Result<()> {
|
||||
let content = serde_yaml::to_string(&self).context("converting Config to yaml")?;
|
||||
let content = toml::to_string(&self).context("converting Config to toml")?;
|
||||
|
||||
let parent = file.parent().context("getting parent of config dir")?;
|
||||
if !parent.is_dir() {
|
||||
|
||||
@@ -25,9 +25,9 @@ use pacdef::path::{get_config_path, get_config_path_old_version, get_group_dir};
|
||||
use pacdef::{Config, Error as PacdefError, Group};
|
||||
|
||||
const MAJOR_UPDATE_MESSAGE: &str = "VERSION UPGRADE
|
||||
You seem to have used version 0.x of pacdef before.
|
||||
Version 1.x changes the syntax of the config files and the command line arguments.
|
||||
Check out https://github.com/steven-omaha/pacdef for new syntax information.
|
||||
You seem to have used version 1.x of pacdef before.
|
||||
In version 2.0 the config file needed to be changed from yaml to toml.
|
||||
Check out https://github.com/steven-omaha/pacdef/blob/main/README.md#configuration for new syntax information.
|
||||
This message will not appear again.
|
||||
------";
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ use std::{env, path::Path};
|
||||
use anyhow::{Context, Result};
|
||||
use path_absolutize::Absolutize;
|
||||
|
||||
const CONFIG_FILE_NAME: &str = "pacdef.yaml";
|
||||
const CONFIG_FILE_NAME_OLD: &str = "pacdef.conf";
|
||||
const CONFIG_FILE_NAME: &str = "pacdef.toml";
|
||||
const CONFIG_FILE_NAME_OLD: &str = "pacdef.yaml";
|
||||
|
||||
/// Get the group directory where all group files are located. This is
|
||||
/// `$XDG_CONFIG_HOME/pacdef/groups`, which defaults to `$HOME/.config/pacdef/groups`.
|
||||
@@ -76,7 +76,7 @@ pub fn get_home_dir() -> Result<PathBuf> {
|
||||
Ok(env::var("HOME").context("getting $HOME variable")?.into())
|
||||
}
|
||||
|
||||
/// Get the path to the pacdef config file. This is `$XDG_CONFIG_HOME/pacdef/pacdef.yaml`.
|
||||
/// Get the path to the pacdef config file. This is `$XDG_CONFIG_HOME/pacdef/pacdef.toml`.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user