Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
Added -ipb options for id, path, both entry
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinosh committed Feb 19, 2024
1 parent 05d41d3 commit f9895d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
24 changes: 17 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,28 @@ async fn main() {
match &args.command {
Command::List {
entry,
entry_both,
entry_id,
entry_path,

root_dir,
timestamp,
modified,
tags,
scores,
sort,
filter,
} => {
let root = provide_root(root_dir);

let entry_output = match entry {
Some(entry) => entry,
None => &EntryOutput::Id,
let entry_output = match (entry, entry_id, entry_path, entry_both) {
(Some(e), false, false, false) => e,
(None, true, false, false) => &EntryOutput::Id,
(None, false, true, false) => &EntryOutput::Path,
(None, false, false, true) => &EntryOutput::Both,
(None, true, true, false) => &EntryOutput::Both,
_ => panic!(
"incompatible entry output options, please choose only one"
),
};

let index = provide_index(&root).expect("could not provide index");
Expand Down Expand Up @@ -133,7 +143,7 @@ async fn main() {

output.push_str(&entry_str);

if timestamp.unwrap_or(false) {
if *modified {
let timestamp_str = datetime
.format("%Y-%m-%d %H:%M:%S.%f")
.to_string();
Expand All @@ -143,11 +153,11 @@ async fn main() {
));
}

if tags.unwrap_or(false) {
if *tags {
output.push_str(&format!(" with tags {}", tags_list));
}

if scores.unwrap_or(false) {
if *scores {
output.push_str(&format!(" with score {}", scores_list));
}

Expand Down
21 changes: 15 additions & 6 deletions src/models/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,23 @@ pub enum Command {
#[clap(long)]
entry: Option<EntryOutput>,

#[clap(long)]
timestamp: Option<bool>,
#[clap(long, short = 'i', action)]
entry_id: bool,

#[clap(long)]
tags: Option<bool>,
#[clap(long, short = 'p', action)]
entry_path: bool,

#[clap(long)]
scores: Option<bool>,
#[clap(long, short = 'b', action)]
entry_both: bool,

#[clap(long, short, action)]
modified: bool,

#[clap(long, short, action)]
tags: bool,

#[clap(long, short, action)]
scores: bool,

#[clap(long)]
sort: Option<Sort>,
Expand Down

0 comments on commit f9895d7

Please sign in to comment.