Skip to content

Commit

Permalink
fix: remove monthly and yearly bound on activity_log file name
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Feb 27, 2024
1 parent 38a4ad4 commit 21906ca
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
13 changes: 6 additions & 7 deletions crates/cli/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use getset::{Getters, MutGetters};
use tracing::{debug, info};
use typed_builder::TypedBuilder;

use pace_core::{get_activity_log_paths, get_config_paths, toml, ActivityLog, PaceConfig};
use pace_core::{
get_activity_log_paths, get_config_paths, toml, ActivityLog, PaceConfig,
PACE_ACTIVITY_LOG_FILENAME, PACE_CONFIG_FILENAME,
};

use crate::prompt::{prompt_activity_log_path, prompt_config_file_path};

Expand Down Expand Up @@ -325,16 +328,12 @@ pub(crate) fn confirmation_or_break(prompt: &str) -> Result<()> {
pub fn craft_setup(term: &Term) -> Result<()> {
let mut config = PaceConfig::default();

let config_paths = get_config_paths("pace.toml")
let config_paths = get_config_paths(PACE_CONFIG_FILENAME)
.into_iter()
.map(|f| f.to_string_lossy().to_string())
.collect::<Vec<String>>();

let current_month_year = chrono::Local::now().format("%Y-%m").to_string();

let activity_log_filename = format!("activity_{current_month_year}.pace.toml");

let activity_log_paths = get_activity_log_paths(&activity_log_filename)
let activity_log_paths = get_activity_log_paths(PACE_ACTIVITY_LOG_FILENAME)
.into_iter()
.map(|f| f.to_string_lossy().to_string())
.collect::<Vec<String>>();
Expand Down
4 changes: 4 additions & 0 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ pub(crate) mod service;
pub(crate) mod storage;
pub(crate) mod util;

pub const PACE_CORE_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const PACE_CONFIG_FILENAME: &str = "pace.toml";
pub const PACE_ACTIVITY_LOG_FILENAME: &str = "activities.pace.toml";

// Re-export commonly used external crates
pub use toml;

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use clap::builder::{styling::AnsiColor, Styles};
use human_panic::setup_panic;
use std::path::PathBuf;

use pace_core::{get_config_paths, PaceConfig};
use pace_core::{get_config_paths, PaceConfig, PACE_CONFIG_FILENAME};

/// Pace Subcommands
/// Subcommands need to be listed in an enum.
Expand Down Expand Up @@ -126,7 +126,7 @@ impl Override<PaceConfig> for EntryPoint {
impl Configurable<PaceConfig> for EntryPoint {
/// Location of the configuration file
fn config_path(&self) -> Option<PathBuf> {
let config_paths = get_config_paths("pace.toml")
let config_paths = get_config_paths(PACE_CONFIG_FILENAME)
.into_iter()
.filter(|f| f.exists())
.collect::<Vec<_>>();
Expand Down

0 comments on commit 21906ca

Please sign in to comment.