Skip to content

Commit 1285f6e

Browse files
committed
feat: work on user experience
- use tables with pretty-printed output (tabular + yansi) - add some more print messages - start working on period select for list - re-enable config cmd but not implemented yet - remove `clap_verbosity_flag` for now as it seems to cause some issues - update docs
1 parent 62eb62a commit 1285f6e

File tree

7 files changed

+262
-64
lines changed

7 files changed

+262
-64
lines changed

Cargo.lock

Lines changed: 63 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "boat-cli"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2024"
55
description = "Basic Opinionated Activity Tracker, a command line interface inspired by bartib"
66
repository = "https://github.com/coko7/boat"
@@ -18,7 +18,7 @@ path = "src/main.rs"
1818
clap = { version = "4.6.0", features = ["derive"] }
1919
env_logger = "0.11.9"
2020
log = "0.4.29"
21-
clap-verbosity-flag = "3.0.4"
21+
# clap-verbosity-flag = "3.0.4"
2222
anyhow = "1.0.102"
2323
directories = "6.0.0"
2424
serde = { version = "1.0.228", features = ["derive"] }
@@ -27,3 +27,5 @@ rusqlite = "0.39.0"
2727
chrono = { version = "0.4.44", features = ["serde"] }
2828
serde_json = "1.0.149"
2929
boat-lib = "0.3.1"
30+
tabular = { version = "0.2.0", features = ["ansi-cell"] }
31+
yansi = "1.0.1"

README.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ This is only the code for the command line application. It relies on [`boat-lib`
1515
> This cli is actively being developed. Since it's in its early stages, things will likely break often.
1616
> Don't use it for now.
1717
18+
## Why was this tool created?
19+
20+
The [`bartib`](https://github.com/nikolassv/bartib) cli is what inspired me to create `boat`.
21+
It's a feature-full tool that I used for a while, but I found it quite limiting for my usage due to its [lack of support for machine-readable output](https://github.com/nikolassv/bartib/pull/26).
22+
That's it, I wanted an activity tracker that I could combine easily with [`jq`](https://github.com/jqlang/jq) and so I decided to make my own tool.
23+
1824
## Installation
1925

2026
The easiest way to install is through [crates.io](https://crates.io/crates/boat-cli):
@@ -29,26 +35,43 @@ cd boat-cli
2935
cargo build --release
3036
```
3137

32-
## Commands
38+
## Usage
3339

40+
To get a feel of how `boat` can be used, you can try `boat help` to get the list of commands:
3441
```help
3542
Basic Opinionated Activity Tracker
3643
37-
Usage: boat [OPTIONS] <COMMAND>
44+
Usage: boat <COMMAND>
3845
3946
Commands:
4047
new Create a new activity
4148
start Start/resume an activity
42-
pause Manage configuration Pause/stop the current activity
49+
config Manage configuration
50+
pause Pause/stop the current activity
4351
modify Modify an activity
4452
delete Delete an activity
4553
get Get the current activity
4654
list List activities and tags
4755
help Print this message or the help of the given subcommand(s)
4856
4957
Options:
50-
-v, --verbose... Increase logging verbosity
51-
-q, --quiet... Decrease logging verbosity
52-
-h, --help Print help
53-
-V, --version Print version
58+
-h, --help Print help
59+
-V, --version Print version
60+
```
61+
62+
If you want to invoke `boat` from your command-line directly, you can make use of a variety of shorter aliases:
63+
```help
64+
Commands:
65+
new n
66+
start s, st, sail
67+
config c, cfg, conf
68+
pause p
69+
modify m, mod
70+
delete d, del
71+
get g
72+
list l, ls
5473
```
74+
I really wanted to have each command start with a different character so that I could assign a single-char alias to all of them.
75+
That explains why some of the commands do not use a more fitting keyword.
76+
Like `stop` would have been a better command than `pause` but since it shares the same starting charcter as the `start` command, I could not use it.
77+
Maybe I will drop this in the future, let's see.

src/cli.rs

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
use std::ops::RangeInclusive;
2+
13
use boat_lib::repository::Id;
2-
use clap::{ArgAction, Args, Parser, Subcommand};
4+
use clap::{ArgAction, Args, Parser, Subcommand, ValueEnum};
35

46
#[derive(Parser)]
57
#[command(
@@ -12,9 +14,9 @@ use clap::{ArgAction, Args, Parser, Subcommand};
1214
pub struct Cli {
1315
#[command(subcommand)]
1416
pub command: Commands,
15-
16-
#[command(flatten)]
17-
pub verbose: clap_verbosity_flag::Verbosity,
17+
//
18+
// #[command(flatten)]
19+
// pub verbose: clap_verbosity_flag::Verbosity,
1820
}
1921

2022
#[derive(Subcommand)]
@@ -30,11 +32,11 @@ pub enum Commands {
3032
Start(SelectActivityArgs),
3133

3234
/// Manage configuration
33-
// #[command(alias = "c", alias = "cfg", alias = "conf")]
34-
// Config {},
35+
#[command(alias = "c", alias = "cfg", alias = "conf")]
36+
Config {},
3537

3638
/// Pause/stop the current activity
37-
#[command(alias = "p")]
39+
#[command(alias = "p", alias = "stop")]
3840
Pause,
3941

4042
/// Modify an activity
@@ -73,27 +75,34 @@ pub enum Commands {
7375
#[derive(Args, Debug)]
7476
#[group(multiple = false)]
7577
pub struct ListActivityArgs {
76-
#[arg(short = 'a', long = "all")]
77-
pub show_all: bool,
78-
79-
#[arg(short = 'r', long = "recent")]
80-
pub show_recent: bool,
81-
82-
#[arg(short = 'c', long = "current")]
83-
pub show_current: bool,
84-
85-
#[arg(short = 't', long = "tags")]
86-
pub show_tags: bool,
87-
88-
/// Output in pretty format
89-
#[arg(short = 'p', long = "pretty")]
90-
pub use_pretty_format: bool,
78+
/// Only show activities matching a certain period
79+
#[arg(short = 'p', long = "period", value_name = "PERIOD", default_value_t = Period::Today, value_enum)]
80+
pub period: Period,
9181

9282
/// Output in JSON
9383
#[arg(short = 'j', long = "json")]
9484
pub use_json_format: bool,
9585
}
9686

87+
#[derive(ValueEnum, Clone, Debug)]
88+
pub enum Period {
89+
#[value(name = "today", alias = "tod", alias = "td")]
90+
Today,
91+
#[value(name = "yesterday", alias = "yes", alias = "yd")]
92+
Yesterday,
93+
#[value(name = "week", alias = "wk")]
94+
ThisWeek,
95+
#[value(name = "last_week")]
96+
LastWeek,
97+
#[value(name = "month", alias = "mo")]
98+
ThisMonth,
99+
// #[value(name = "range")]
100+
// DateRange {
101+
// #[arg(value_parser = range_parser)]
102+
// range: RangeInclusive<u32>,
103+
// },
104+
}
105+
97106
#[derive(Args, Debug)]
98107
#[group(multiple = false)]
99108
pub struct PrintActivityArgs {

0 commit comments

Comments
 (0)