Skip to content

Commit

Permalink
feat(commands): rename review to reflect
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 19, 2024
1 parent 4be9ae5 commit d91f3b3
Show file tree
Hide file tree
Showing 34 changed files with 320 additions and 294 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ command-line interface (CLI) that encourages focused work sessions, thoughtful
reflection on task durations, and a harmonious balance between work and rest.

Whether you're a developer, a writer, or anyone who values structured time
management, pace provides the framework to log activities, review progress, and
optimize how you spend your time.
management, pace provides the framework to log activities, reflect on progress,
and optimize how you spend your time.

⚠️ **Note:** `pace` is currently in active development and is not yet ready for
production use. Expect breaking changes and incomplete features. We encourage
Expand Down
10 changes: 5 additions & 5 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ possible values, and descriptions to help you configure Pace to your liking.
| `category_separator` | `"::"` | - | The separator used for categories in the CLI. | |
| `default_priority` | `"medium"` | `"low"`, `"medium"`, `"high"` | Default priority for new tasks. | |

## Reviews
## Reflections

| Option | Default Value | Possible Values | Description |
| ------------------ | -------------------------- | ------------------------------------------ | ---------------------------------------- |
| `review_format` | `"console"` | `"console", "pdf"`, `"html"`, `"markdown"` | Format of the reviews generated by Pace. |
| `review_directory` | `"/path/to/your/reviews/"` | - | Directory where reviews will be stored. |
| Option | Default Value | Possible Values | Description |
| ----------- | ------------------------------ | ------------------------------------------ | -------------------------------------------- |
| `format` | `"console"` | `"console", "pdf"`, `"html"`, `"markdown"` | Format of the reflections generated by Pace. |
| `directory` | `"/path/to/your/reflections/"` | - | Directory where reflections will be stored. |

## Export

Expand Down
10 changes: 5 additions & 5 deletions config/pace.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ category-separator = "::"
# Default priority for new tasks
default-priority = "medium"

[reviews]
# Format of the review generated by the pace: "pdf", "html", "markdown", etc.
review-format = "html"
# Directory where the reviews will be stored
review-directory = "/path/to/your/reviews/"
[reflections]
# Format of the reflections generated by the pace: "pdf", "html", "markdown", etc.
format = "html"
# Directory where the reflections will be stored
directory = "/path/to/your/reflections/"

[export]
include-tags = true
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pub mod docs;
pub mod end;
pub mod hold;
pub mod now;
pub mod reflect;
pub mod resume;
pub mod review;

use getset::Getters;
use typed_builder::TypedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ use clap::Parser;
use crate::{
config::PaceConfig,
domain::{
activity::ActivityKind, filter::FilterOptions, review::ReviewFormatKind,
activity::ActivityKind, filter::FilterOptions, reflection::ReflectionsFormatKind,
time::get_time_frame_from_flags,
},
error::{PaceResult, UserMessage},
service::{activity_store::ActivityStore, activity_tracker::ActivityTracker},
storage::get_storage_from_config,
};

/// `review` subcommand options
/// `reflect` subcommand options
#[derive(Debug, Getters)]
#[getset(get = "pub")]
#[cfg_attr(feature = "clap", derive(Parser))]
pub struct ReviewCommandOptions {
pub struct ReflectCommandOptions {
/// Filter by activity kind (e.g., activity, task)
#[cfg_attr(
feature = "clap",
Expand All @@ -44,9 +44,9 @@ pub struct ReviewCommandOptions {
feature = "clap",
clap(short, long, name = "Output Format", alias = "format")
)]
output_format: Option<ReviewFormatKind>,
output_format: Option<ReflectionsFormatKind>,

/// Export the review report to a specified file
/// Export the reflections to a specified file
#[cfg_attr(
feature = "clap",
clap(short, long, name = "Export File", alias = "export")
Expand Down Expand Up @@ -79,51 +79,53 @@ pub struct ReviewCommandOptions {
expensive_flags: ExpensiveFlags,
}

impl ReviewCommandOptions {
impl ReflectCommandOptions {
#[tracing::instrument(skip(self))]
pub fn handle_review(&self, config: &PaceConfig) -> PaceResult<UserMessage> {
pub fn handle_reflect(&self, config: &PaceConfig) -> PaceResult<UserMessage> {
let activity_store = ActivityStore::with_storage(get_storage_from_config(config)?)?;

let activity_tracker = ActivityTracker::with_activity_store(activity_store);

let time_frame = get_time_frame_from_flags(self.time_flags(), self.date_flags())?;

debug!("Displaying review for time frame: {}", time_frame);
debug!("Displaying reflection for time frame: {}", time_frame);

Check warning on line 91 in crates/core/src/commands/reflect.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/commands/reflect.rs#L91

Added line #L91 was not covered by tests

let Some(review_summary) =
activity_tracker.generate_review_summary(FilterOptions::from(self), time_frame)?
let Some(reflections) =
activity_tracker.generate_reflection(FilterOptions::from(self), time_frame)?
else {
return Ok(UserMessage::new(
"No activities found for the specified time frame",
));
};

match self.output_format() {
Some(ReviewFormatKind::Console) | None => {
return Ok(UserMessage::new(review_summary.to_string()));
Some(ReflectionsFormatKind::Console) | None => {
return Ok(UserMessage::new(reflections.to_string()));
}
Some(ReviewFormatKind::Json) => {
let json = serde_json::to_string_pretty(&review_summary)?;
Some(ReflectionsFormatKind::Json) => {
let json = serde_json::to_string_pretty(&reflections)?;

debug!("Review summary: {}", json);
debug!("Reflection: {}", json);

Check warning on line 108 in crates/core/src/commands/reflect.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/commands/reflect.rs#L108

Added line #L108 was not covered by tests

// write to file if export file is specified
if let Some(export_file) = self.export_file() {
std::fs::write(export_file, json)?;

return Ok(UserMessage::new(format!(
"Review report generated: {}",
"Reflection generated: {}",
export_file.display()
)));
}

return Ok(UserMessage::new(json));
}

Some(ReviewFormatKind::Html) => unimplemented!("HTML format not yet supported"),
Some(ReviewFormatKind::Csv) => unimplemented!("CSV format not yet supported"),
Some(ReviewFormatKind::Markdown) => unimplemented!("Markdown format not yet supported"),
Some(ReviewFormatKind::PlainText) => {
Some(ReflectionsFormatKind::Html) => unimplemented!("HTML format not yet supported"),
Some(ReflectionsFormatKind::Csv) => unimplemented!("CSV format not yet supported"),
Some(ReflectionsFormatKind::Markdown) => {
unimplemented!("Markdown format not yet supported")
}
Some(ReflectionsFormatKind::PlainText) => {
unimplemented!("Plain text format not yet supported")
}
}
Expand All @@ -136,20 +138,20 @@ impl ReviewCommandOptions {
#[cfg_attr(
feature = "clap", clap(group = clap::ArgGroup::new("date-flag").multiple(true)))]
pub struct DateFlags {
/// Show the review for a specific date, mutually exclusive with `from` and `to`. Format: YYYY-MM-DD
/// Show the reflection for a specific date, mutually exclusive with `from` and `to`. Format: YYYY-MM-DD
#[cfg_attr(
feature = "clap",
clap(long, group = "date-flag", name = "Specific Date", exclusive = true)
)]
#[builder(setter(strip_option))]
date: Option<NaiveDate>,

/// Start date for the review period. Format: YYYY-MM-DD
/// Start date for the reflection period. Format: YYYY-MM-DD
#[cfg_attr(feature = "clap", clap(long, group = "date-flag", name = "Start Date"))]
#[builder(setter(strip_option))]
from: Option<NaiveDate>,

/// End date for the review period. Format: YYYY-MM-DD
/// End date for the reflection period. Format: YYYY-MM-DD
#[cfg_attr(feature = "clap", clap(long, group = "date-flag", name = "End Date"))]
#[builder(setter(strip_option))]
to: Option<NaiveDate>,
Expand All @@ -160,15 +162,15 @@ pub struct DateFlags {
)]
#[cfg_attr(feature = "clap", derive(Parser))]
pub struct ExpensiveFlags {
/// Include detailed time logs in the review
/// Include detailed time logs in the reflection
#[cfg_attr(feature = "clap", clap(long))]
detailed: bool,

/// Enable comparative insights against a previous period
#[cfg_attr(feature = "clap", clap(long))]
comparative: bool,

/// Enable personalized recommendations based on review data
/// Enable personalized recommendations based on reflection data
#[cfg_attr(feature = "clap", clap(long))]
recommendations: bool,
}
Expand All @@ -181,32 +183,32 @@ pub struct ExpensiveFlags {
// and because it's easier to deal with clap in this way.
#[allow(clippy::struct_excessive_bools)]
pub struct TimeFlags {
/// Show the review for the current day
/// Show the reflection for the current day
#[cfg_attr(feature = "clap", clap(long, group = "time-flag"))]
#[builder(setter(strip_bool))]
today: bool,

/// Show the review for the previous day
/// Show the reflection for the previous day
#[cfg_attr(feature = "clap", clap(long, group = "time-flag"))]
#[builder(setter(strip_bool))]
yesterday: bool,

/// Show the review for the current week
/// Show the reflection for the current week
#[cfg_attr(feature = "clap", clap(long, group = "time-flag"))]
#[builder(setter(strip_bool))]
current_week: bool,

/// Show the review for the previous week
/// Show the reflection for the previous week
#[cfg_attr(feature = "clap", clap(long, group = "time-flag"))]
#[builder(setter(strip_bool))]
last_week: bool,

/// Show the review for the current month
/// Show the reflection for the current month
#[cfg_attr(feature = "clap", clap(long, group = "time-flag"))]
#[builder(setter(strip_bool))]
current_month: bool,

/// Show the review for the previous month
/// Show the reflection for the previous month
#[cfg_attr(feature = "clap", clap(long, group = "time-flag"))]
#[builder(setter(strip_bool))]
last_month: bool,
Expand Down
18 changes: 9 additions & 9 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use directories::ProjectDirs;
use strum_macros::EnumString;

use crate::{
domain::{priority::ItemPriorityKind, review::ReviewFormatKind},
domain::{priority::ItemPriorityKind, reflection::ReflectionsFormatKind},
error::{PaceErrorKind, PaceResult},
};

Expand All @@ -26,10 +26,10 @@ pub struct PaceConfig {
#[getset(get = "pub", get_mut = "pub")]
general: GeneralConfig,

/// Review configuration for the pace application
/// Reflections configuration for the pace application
#[serde(default, skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", get_mut = "pub")]
reviews: Option<ReviewConfig>,
reflections: Option<ReflectionsConfig>,

/// Export configuration for the pace application
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -152,16 +152,16 @@ impl Default for GeneralConfig {
}
}

/// The review configuration for the pace application
/// The reflections configuration for the pace application
#[derive(Debug, Deserialize, Default, Serialize, Getters, Clone)]
#[getset(get = "pub")]
#[serde(rename_all = "kebab-case")]
pub struct ReviewConfig {
/// The directory to store the review files
review_directory: PathBuf,
pub struct ReflectionsConfig {
/// The directory to store the reflections
directory: PathBuf,

/// The format for the review
review_format: ReviewFormatKind,
/// The format for the reflections
format: ReflectionsFormatKind,
}

/// The export configuration for the pace application
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod inbox;
pub mod intermission;
pub mod priority;
pub mod project;
pub mod review;
pub mod reflection;
pub mod status;
pub mod tag;
pub mod task;
Expand Down
3 changes: 3 additions & 0 deletions crates/core/src/domain/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ mod tests {
kind = "activity"
"#;

// 2022-08-17T21:43:13+08:00
// Local::now().to_rfc3339()

let activity: Activity = toml::from_str(toml)?;

assert_eq!(activity.category.as_ref().ok_or("No category.")?, "Work");
Expand Down
10 changes: 5 additions & 5 deletions crates/core/src/domain/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strum::EnumIter;
use typed_builder::TypedBuilder;

use crate::{
commands::review::ReviewCommandOptions,
commands::reflect::ReflectCommandOptions,
domain::{activity::ActivityGuid, time::TimeRangeOptions},
};

Expand Down Expand Up @@ -98,16 +98,16 @@ pub struct FilterOptions {
case_sensitive: bool,
}

impl From<ReviewCommandOptions> for FilterOptions {
fn from(options: ReviewCommandOptions) -> Self {
impl From<ReflectCommandOptions> for FilterOptions {
fn from(options: ReflectCommandOptions) -> Self {

Check warning on line 102 in crates/core/src/domain/filter.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/domain/filter.rs#L102

Added line #L102 was not covered by tests
Self {
category: options.category().clone(),
case_sensitive: *options.case_sensitive(),
}
}
}
impl From<&ReviewCommandOptions> for FilterOptions {
fn from(options: &ReviewCommandOptions) -> Self {
impl From<&ReflectCommandOptions> for FilterOptions {
fn from(options: &ReflectCommandOptions) -> Self {

Check warning on line 110 in crates/core/src/domain/filter.rs

View check run for this annotation

Codecov / codecov/patch

crates/core/src/domain/filter.rs#L110

Added line #L110 was not covered by tests
Self {
category: options.category().clone(),
case_sensitive: *options.case_sensitive(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::domain::{
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[serde(rename_all = "kebab-case")]
#[non_exhaustive]
pub enum ReviewFormatKind {
pub enum ReflectionsFormatKind {
#[default]
Console,
Json,
Expand All @@ -48,7 +48,7 @@ pub type SummaryGroupByCategory = BTreeMap<SummaryCategories, SummaryActivityGro
Debug, TypedBuilder, Serialize, Getters, Setters, MutGetters, Clone, Eq, PartialEq, Default,
)]
#[getset(get = "pub", get_mut = "pub", set = "pub")]
pub struct ReviewSummary {
pub struct ReflectionSummary {
/// The time range of the review period.
time_range: TimeRangeOptions,

Expand All @@ -67,7 +67,7 @@ pub struct ReviewSummary {
// suggestions: Vec<String>,
}

impl ReviewSummary {
impl ReflectionSummary {
#[must_use]
pub fn new(
time_range: TimeRangeOptions,
Expand Down Expand Up @@ -97,7 +97,7 @@ impl ReviewSummary {
}

// TODO!: Refine the display of the review summary
impl std::fmt::Display for ReviewSummary {
impl std::fmt::Display for ReflectionSummary {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut builder = Builder::new();

Expand Down
Loading

0 comments on commit d91f3b3

Please sign in to comment.