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

Commit

Permalink
Added Entry Output Link and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinosh committed Mar 8, 2024
1 parent 0428d9b commit 8485b2f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
34 changes: 23 additions & 11 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ $ ark-cli list ~/Pictures/
```

But it's a bit boring and doesn't really tell anything, right? Various flags should be used to gain more knowledge about your collections of resources:
* `--entry=id|path|both` to show the path,the id or both of a resource
* `--entry=id|path|both|link` to show the path,the id or both of a resource
* `--timestamp=true` to show or not the last modified timestamp of a resource
* `--tags=true` to show or not the tags for every resource
* `--scores=true` to show or not the scores for every resource
Expand All @@ -85,28 +85,40 @@ For instance, you can list files with their paths and attached tags:
```
$ ark-cli list -pt
30-4257856154 with tags search
18-1909444406 with tags hello
22-207093268 with tags search,engine
38-103010298 with tags NO_TAGS
30-4257856154 search
18-1909444406 hello
22-207093268 search,engine
38-103010298 NO_TAGS
```

You Can list the links of the files

```
$ark-cli list -l
https://google.com
https://news.ycombinator.com
https://youtube.com
https://github.com
```

Or, sort by score:
```
$ ark-cli list -s --sort=asc
30-4257856154 with score NO_SCORE
18-1909444406 with score 2
38-103010298 with score 10
22-207093268 with score 15
30-4257856154 NO_SCORE
18-1909444406 2
38-103010298 10
22-207093268 15
```

Finally, you can filter resources using their tags:
```
$ /tmp/ark-cli list -t --filter=search
30-4257856154 with tags search
22-207093268 with tags search,engine
30-4257856154 search
22-207093268 search,engine
```

## :zap: Low-level utilities :zap:
Expand Down
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async fn main() -> anyhow::Result<()> {
entry,
entry_id,
entry_path,
entry_link,

root_dir,
modified,
Expand All @@ -82,12 +83,13 @@ async fn main() -> anyhow::Result<()> {
} => {
let root = provide_root(root_dir)?;

let entry_output = match (entry, entry_id, entry_path) {
(Some(e), false, false) => Ok(*e),
(None, true, false) => Ok(EntryOutput::Id),
(None, false, true) => Ok(EntryOutput::Path),
(None, true, true) => Ok(EntryOutput::Both),
(None, false, false) => Ok(EntryOutput::Id),
let entry_output = match (entry, entry_id, entry_path, entry_link) {
(Some(e), false, false, false) => Ok(*e),
(None, true, false, false) => Ok(EntryOutput::Id),
(None, false, true, false) => Ok(EntryOutput::Path),
(None, true, true, false) => Ok(EntryOutput::Both),
(None, false, false, false) => Ok(EntryOutput::Id),
(None, false, false, true) => Ok(EntryOutput::Link),
_ => Err(AppError::InvalidEntryOption),
}?;

Expand Down
3 changes: 3 additions & 0 deletions src/models/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub enum Command {
#[clap(long, short = 'p', action)]
entry_path: bool,

#[clap(long, short = 'l', action)]
entry_link: bool,

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

Expand Down
1 change: 1 addition & 0 deletions src/models/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl std::str::FromStr for EntryOutput {
"id" => Ok(EntryOutput::Id),
"path" => Ok(EntryOutput::Path),
"both" => Ok(EntryOutput::Both),
"link" => Ok(EntryOutput::Link),
_ => Err("Entry output must be either 'id', 'path' or 'both'"),
}
}
Expand Down

0 comments on commit 8485b2f

Please sign in to comment.