From 57a3e7757c8b98116b5f8ed9c5658663c1094701 Mon Sep 17 00:00:00 2001 From: el7cosmos Date: Thu, 17 Sep 2020 16:23:26 +0700 Subject: [PATCH] Attendance command --- .github/workflows/publish.yaml | 19 ++++++ .github/workflows/release.yml | 2 +- Cargo.lock | 2 +- Cargo.toml | 6 +- src/attendance/checkin.rs | 5 ++ src/attendance/checkout.rs | 5 ++ src/attendance/mod.rs | 117 +++++++++++++++++++++++++++++++++ src/client/mod.rs | 62 ++++++++++++++++- src/config.rs | 6 +- src/main.rs | 6 ++ 10 files changed, 222 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish.yaml create mode 100644 src/attendance/checkin.rs create mode 100644 src/attendance/checkout.rs create mode 100644 src/attendance/mod.rs diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..e4d6fd4 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,19 @@ +name: Publish + +on: + push: + tags: + - '*' + +env: + CARGO_TERM_COLOR: always + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - run: cargo publish diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 488262c..926412a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: - name: Archive run: | cp target/${{ matrix.target }}/release/${{ matrix.bin }} . - tar czf talenta.tar.gz ${{ matrix.bin }} README.md + tar czf talenta.tar.gz ${{ matrix.bin }} LICENSE-APACHE LICENSE-MIT README.md - name: Upload Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 diff --git a/Cargo.lock b/Cargo.lock index afc67b9..150d713 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1124,7 +1124,7 @@ dependencies = [ [[package]] name = "talenta" -version = "0.1.0" +version = "0.2.0" dependencies = [ "ansi_term 0.12.1", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index b9a17cd..d5017ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "talenta" -version = "0.1.0" +version = "0.2.0" authors = ["el7cosmos "] edition = "2018" description = "Talenta CLI" @@ -10,6 +10,10 @@ license = "MIT OR Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +exclude = [ + ".github/*" +] + [dependencies] ansi_term = "0.12" chrono = "0.4" diff --git a/src/attendance/checkin.rs b/src/attendance/checkin.rs new file mode 100644 index 0000000..d1686ff --- /dev/null +++ b/src/attendance/checkin.rs @@ -0,0 +1,5 @@ +use structopt::StructOpt; + +#[derive(Default, Debug, StructOpt)] +#[structopt(about = "Request checkin only attendance")] +pub(super) struct Checkin {} diff --git a/src/attendance/checkout.rs b/src/attendance/checkout.rs new file mode 100644 index 0000000..e2ff107 --- /dev/null +++ b/src/attendance/checkout.rs @@ -0,0 +1,5 @@ +use structopt::StructOpt; + +#[derive(Default, Debug, StructOpt)] +#[structopt(about = "Request checkout only attendance")] +pub(super) struct Checkout {} diff --git a/src/attendance/mod.rs b/src/attendance/mod.rs new file mode 100644 index 0000000..b8b384e --- /dev/null +++ b/src/attendance/mod.rs @@ -0,0 +1,117 @@ +mod checkin; +mod checkout; + +use crate::attendance::checkin::Checkin; +use crate::attendance::checkout::Checkout; +use crate::client::Client; +use crate::config::Config; +use crate::date::Date; +use crate::time::Time; +use crate::Command; +use ansi_term::Colour; +use dialoguer::theme::ColorfulTheme; +use dialoguer::Input; +use reqwest::StatusCode; +use structopt::clap::{Error, ErrorKind}; +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +enum AttendanceCommand { + Checkin(Checkin), + Checkout(Checkout), +} + +#[derive(Default, StructOpt)] +#[structopt(about = "Request attendance")] +pub(super) struct Attendance { + #[structopt(skip)] + client: Client, + #[structopt(skip)] + theme: ColorfulTheme, + + #[structopt(long)] + reason: Option, + #[structopt( + default_value, + long, + help = "Effective date (yyyy-mm-dd)", + value_name = "DATE" + )] + date: Date, + #[structopt(long, value_name = "TIME")] + checkin_time: Option