mclang / kiho-wt-puncher

Rust CLI app to make Kiho worktime login/logout punches using Kiho API
GNU General Public License v3.0
1 stars 0 forks source link

Implement `get latest today` #15

Open mclang opened 2 months ago

mclang commented 2 months ago

Problem

Many times it would be nice to be able see what has happened today instead of e.g latest 15 punch lines.

Solution

Change get_latest_punch function to accept also today (and maybe yesterday also?) and print only punch lines done today.

mclang commented 2 months ago

Needed changes

Enum CliGetWhat:

    /// Get latest COUNT worktime BREAK/LOGIN/LOGOUT punch lines
    Latest {
        /// Number of punch lines to get
        #[arg(value_name = "count")]
        cnt: u32,
        /// Punch type to get. (default: all types)
        #[arg(value_enum, value_name="type")]
        typ: Option<PunchType>,
    },

Function get_latest_punch(api_key: String, punch_type: Option<PunchType>, punch_count: u32)

Main function match &CLIARGS.command: CliGetWhat::Latest { cnt, typ } => get_latest_punch(config.api_key, *typ, *cnt),