Skip to content

Commit

Permalink
feat: i6-timer crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kruserr committed Oct 12, 2024
1 parent 5d9afc3 commit a96dfc6
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ jobs:
- name: Publish
run: |
cargo publish -p i6-pack --token ${{ secrets.CARGO_TOKEN }}
cargo publish -p i6-http --token ${{ secrets.CARGO_TOKEN }}
cargo publish -p i6-timer --token ${{ secrets.CARGO_TOKEN }}
cargo publish -p i6-shell --token ${{ secrets.CARGO_TOKEN }}
cargo publish -p i6 --token ${{ secrets.CARGO_TOKEN }}
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resolver = "2"
members = [
"i6-pack",
"i6-http",
"i6-timer",
"i6-shell",
"i6",

Expand Down
16 changes: 16 additions & 0 deletions i6-timer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "i6-timer"
version = "0.1.16" # prepare_release.sh
edition = "2021"
license = "AGPL-3.0"
authors = ["kruserr"]
readme = "../README.md"
repository = "https://github.com/kruserr/i6"
description = "A cli timer tool"
keywords = ["cli", "terminal", "utility", "tool", "command"]
categories = ["command-line-interface", "command-line-utilities", "development-tools"]

[lints]
workspace = true

[dependencies]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions i6/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ clap = "4"

i6-pack = { version = "0.1", path = "../i6-pack" }
i6-http = { version = "0.1", path = "../i6-http" }
i6-timer = { version = "0.1", path = "../i6-timer" }
i6-shell = { version = "0.1", path = "../i6-shell" }

# for db command
Expand Down
1 change: 0 additions & 1 deletion i6/src/lib.rs

This file was deleted.

21 changes: 11 additions & 10 deletions i6/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let https_id = "https";
let pack_id = "pack";
let unpack_id = "unpack";
let timer_id = "timer";
let sh_id = "sh";

let matches = Command::new("i6")
Expand All @@ -31,7 +32,7 @@ fn main() -> Result<(), Box<dyn Error>> {
)
.subcommand(Command::new(sh_id).about("Start an interactive shell"))
.subcommand(
Command::new("timer")
Command::new(timer_id)
.about("Manages timers")
.arg(Arg::new("minutes").index(1).value_parser(value_parser!(String)))
.arg(Arg::new("name").index(2).value_parser(value_parser!(String)))
Expand Down Expand Up @@ -143,34 +144,34 @@ fn main() -> Result<(), Box<dyn Error>> {
)?;
}

if let Some(matches) = matches.subcommand_matches("timer") {
if let Some(matches) = matches.subcommand_matches(timer_id) {
if let Some(matches) = matches.subcommand_matches("create") {
let temp_string = &String::new();
let minutes = matches.get_one::<String>("minutes").unwrap_or(temp_string);
let name = matches.get_one::<String>("name").unwrap_or(temp_string);
i6::timer::create::create_timer(minutes, name);
i6_timer::create::create_timer(minutes, name);
} else if matches.subcommand_matches("list").is_some() {
i6::timer::list::list_timers();
i6_timer::list::list_timers();
} else if let Some(matches) = matches.subcommand_matches("stop") {
if matches.contains_id("all") {
i6::timer::stop::stop_all_timers();
i6_timer::stop::stop_all_timers();
} else {
i6::timer::stop::stop_timer(
i6_timer::stop::stop_timer(
matches.get_one::<String>("name").unwrap_or(&"".to_string()),
);
}
} else if let Some(matches) = matches.subcommand_matches("history") {
if matches.contains_id("json") {
i6::timer::print::print_history_json();
i6_timer::print::print_history_json();
} else {
i6::timer::print::print_history();
i6_timer::print::print_history();
}
} else if let (Some(minutes), Some(name)) =
(matches.get_one::<String>("minutes"), matches.get_one::<String>("name"))
{
i6::timer::create::create_timer(minutes, name);
i6_timer::create::create_timer(minutes, name);
} else if let Some(minutes) = matches.get_one::<String>("minutes") {
i6::timer::create::create_timer(minutes, "");
i6_timer::create::create_timer(minutes, "");
}
}

Expand Down
1 change: 1 addition & 0 deletions tooling/prepare_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bump_version () {

sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i i6-pack/Cargo.toml
sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i i6-http/Cargo.toml
sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i i6-timer/Cargo.toml
sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i i6-shell/Cargo.toml
sed "s/^version = .* $msg$/version = \"${1#v}\" $msg/" -i i6/Cargo.toml

Expand Down

0 comments on commit a96dfc6

Please sign in to comment.