Skip to content

Commit

Permalink
cli/config: allow checking for unpushed / obsolete updates
Browse files Browse the repository at this point in the history
  • Loading branch information
decathorpe committed Feb 24, 2020
1 parent 069aefd commit 021c53f
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 98 deletions.
46 changes: 20 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@ use std::fs::read_to_string;
use serde::Deserialize;

/// This struct represents the contents of a `~/.config/fedora.toml` file.
/// It includes a mandatory `[FAS]` section, and optional sections for tools.
/// It should look something like this:
///
/// ```toml
/// [FAS]
/// username = USERNAME
///
/// [fedora-update-feedback]
/// check-obsoleted = false
/// check-pending = true
/// check-unpushed = true
/// ```
#[derive(Debug, Deserialize)]
pub struct FedoraConfig {
/// This section contains information about the user's FAS account.
#[serde(rename(deserialize = "FAS"))]
pub fas: FASConfig,
/// This section contains configuration for fedora-update-feedback.
#[serde(rename(deserialize = "fedora-update-feedback"))]
pub fuf: Option<FUFConfig>,
}

/// This config file section contains information about the current user's FAS account.
Expand All @@ -17,6 +32,20 @@ pub struct FASConfig {
pub username: String,
}

/// This config file section contains settings for fedora-update-feedback.
#[derive(Debug, Deserialize)]
pub struct FUFConfig {
/// Check for installed obsolete updates
#[serde(rename = "check-obsoleted")]
pub check_obsoleted: Option<bool>,
/// Check for installed pending updates
#[serde(rename = "check-pending")]
pub check_pending: Option<bool>,
/// Check for installed unpushed updates
#[serde(rename = "check-unpushed")]
pub check_unpushed: Option<bool>,
}

/// This helper function reads and parses the configuration file.
pub fn get_config() -> Result<FedoraConfig, String> {
let home = match dirs::home_dir() {
Expand Down
Loading

0 comments on commit 021c53f

Please sign in to comment.