forked from ARK-Builders/ark-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move ark-cli to ark-rust but maintain git history
Signed-off-by: Tarek <[email protected]>
- Loading branch information
1 parent
bcbaace
commit 3131a5b
Showing
19 changed files
with
2,150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "ark-cli" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "ark-cli" | ||
|
||
[dependencies] | ||
tokio = { version = "1.35.1", features = ["full"] } | ||
arklib = { git = "https://github.com/ARK-Builders/arklib", rev = "2c7ceda" } | ||
clap = { version = "3.0.10", features = ["derive"] } | ||
env_logger = "0.9.0" | ||
fs_extra = "1.2.0" | ||
walkdir = "2.3.2" | ||
home = "0.5.3" | ||
url = { version = "2.2.2", features = ["serde"] } | ||
serde_json = "1.0.82" | ||
serde = { version = "1.0.138", features = ["derive"] } | ||
chrono = "0.4.34" | ||
anyhow = "1.0.80" | ||
thiserror = "1.0.57" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Ark-CLI | ||
|
||
### Installation | ||
|
||
To compile you will need openssl libraries and headers: | ||
|
||
```shell | ||
# macOS (Homebrew) | ||
$ brew install openssl@3 | ||
|
||
# macOS (MacPorts) | ||
$ sudo port install openssl | ||
|
||
# macOS (pkgsrc) | ||
$ sudo pkgin install openssl | ||
|
||
# Arch Linux | ||
$ sudo pacman -S pkg-config openssl | ||
|
||
# Debian and Ubuntu | ||
$ sudo apt-get install pkg-config libssl-dev | ||
|
||
# Fedora | ||
$ sudo dnf install pkg-config perl-FindBin openssl-devel | ||
|
||
# Alpine Linux | ||
$ apk add pkgconfig openssl-dev | ||
``` | ||
|
||
### Usage | ||
|
||
```shell | ||
ark-cli <SUBCOMMAND> | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
|
||
SUBCOMMANDS: | ||
backup | ||
collisions | ||
help Print this message or the help of the given subcommand(s) | ||
link | ||
monitor | ||
render | ||
|
||
``` | ||
|
||
#### Backup | ||
```shell | ||
USAGE: | ||
ark-cli backup [ROOTS_CFG] | ||
|
||
ARGS: | ||
<ROOTS_CFG> | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
``` | ||
|
||
#### Collisions | ||
```shell | ||
USAGE: | ||
ark-cli collisions [ROOT_DIR] | ||
|
||
ARGS: | ||
<ROOT_DIR> | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
``` | ||
|
||
#### Link | ||
```shell | ||
USAGE: | ||
ark-cli link <SUBCOMMAND> | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
|
||
SUBCOMMANDS: | ||
create | ||
help Print this message or the help of the given subcommand(s) | ||
load | ||
``` | ||
|
||
#### Monitor | ||
```shell | ||
USAGE: | ||
ark-cli monitor [ARGS] | ||
|
||
ARGS: | ||
<ROOT_DIR> | ||
<INTERVAL> | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
``` | ||
|
||
#### Render | ||
```shell | ||
USAGE: | ||
ark-cli render [ARGS] | ||
|
||
ARGS: | ||
<PATH> | ||
<QUALITY> | ||
|
||
OPTIONS: | ||
-h, --help Print help information | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
# Usage | ||
|
||
## Get started | ||
|
||
Create an empty dir: | ||
``` | ||
mkdir /tmp/test | ||
cd /tmp/test | ||
``` | ||
|
||
Let's fill it with something. One of the simplest ways to create resources it is to save a link to web page using `ark-cli link` command: | ||
``` | ||
$ ark-cli link create . http://google.com goo | ||
$ ark-cli link create . http://duckduckgo.com duck | ||
``` | ||
|
||
We can use `ark-cli list` to see just created resources: | ||
``` | ||
22-207093268 | ||
18-1909444406 | ||
``` | ||
|
||
These are just ids, derived from the URLs themselves. | ||
|
||
Now, the dir structure should resemble this: | ||
``` | ||
/tmp/test | ||
└───.ark | ||
├───cache | ||
│ ├───metadata | ||
│ └───previews | ||
│ | ||
└───user | ||
├───properties | ||
├───scores | ||
└───tags | ||
``` | ||
|
||
### Label your data | ||
|
||
You can attach various metadata to your data, e.g. tags: | ||
``` | ||
$ ark-cli file append . tags 22-207093268 search,engine | ||
``` | ||
|
||
The same way we can append scores: | ||
``` | ||
$ ark-cli file append . scores 22-207093268 15 | ||
``` | ||
|
||
Generic metadata is possible using JSON-based properties: | ||
``` | ||
$ ark-cli file append . properties 22-207093268 favorites:false,ai:true --format=json | ||
``` | ||
|
||
### Navigate your data | ||
|
||
The simplest command to observe your resources is `list`: | ||
``` | ||
$ ark-cli list | ||
18-1909444406 | ||
22-207093268 | ||
``` | ||
|
||
You can also target this command to other folders: | ||
``` | ||
$ ark-cli list ~/Pictures/ | ||
58922-3276384608 | ||
62591-2492670715 | ||
723145-720506115 | ||
125308-3041567246 | ||
``` | ||
|
||
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|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 | ||
* `--sort=asc|desc` to sort resources by asc or dsc order of scores | ||
* `--filter=query` to filter resources by their tags | ||
|
||
For instance, you can list files with their paths and attached tags: | ||
``` | ||
$ ark-cli list -pt | ||
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 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 search | ||
22-207093268 search,engine | ||
``` | ||
|
||
## :zap: Low-level utilities :zap: | ||
|
||
There are commands which could be useful with time, when you grasp the basic concepts. Some of these commands also can be useful for debugging [ArkLib](https://github.com/ARK-Builders/ark-rust). | ||
|
||
### Retrieve the metadata | ||
|
||
You can read these properties: | ||
``` | ||
$ ark-cli file read . properties 22-207093268 | ||
{"ai":"true","desc":null,"favorites":"false","title":"duck"} | ||
``` | ||
|
||
As well as scores or tags: | ||
``` | ||
$ ark-cli file read . scores 22-207093268 | ||
15 | ||
$ ark-cli file read . tags 22-207093268 | ||
search,engine | ||
``` | ||
|
||
### Inspect storages | ||
|
||
It's also possible to list resources having some metadata in a particular storage: | ||
``` | ||
$ ark-cli storage list . properties | ||
22-207093268 | ||
18-1909444406 | ||
$ ark-cli storage list . tags | ||
22-207093268 | ||
$ ark-cli storage list . scores | ||
22-207093268 | ||
``` | ||
|
||
Note that, in this example, resource with id `18-1909444406` is listed only in `properties` storage since it lacks any metadata in `tags` and `scores` storages. The `ark-cli storage list` command only lists entries of a particular storage, not all resources. | ||
|
||
### Inspect versions | ||
|
||
For delving into history of storage mutations, we made `--versions` flag: | ||
``` | ||
$ ark-cli storage list . properties --versions=true | ||
version name machine path | ||
2 22-207093268 0592a937-a5d1-4843-8f03-ae0d6a9e77b5 ./.ark/user/properties/22-207093268/22-207093268_0592a937-a5d1-4843-8f03-ae0d6a9e77b5.2 | ||
1 18-1909444406 0592a937-a5d1-4843-8f03-ae0d6a9e77b5 ./.ark/user/properties/18-1909444406/18-1909444406_0592a937-a5d1-4843-8f03-ae0d6a9e77b5.1 | ||
``` | ||
|
||
Each storage mutation made by `ark-cli file append` or `ark-cli file insert` commands increases the number in `version` column. Versions help to prevent dirty-writes caused by using same storages by separate apps, or devices. | ||
|
||
The `properties` storage is _folder-based_, but same command can be used with _file-based_ storages like `tags`: | ||
``` | ||
$ ark-cli storage list . tags --versions=true | ||
Loading app id at /home/kirill/.ark... | ||
id value | ||
22-207093268 search,engine | ||
$ ark-cli file append . tags 22-207093268 wow | ||
$ ark-cli storage list . tags --versions=true | ||
id value | ||
22-207093268 search,engine | ||
22-207093268 wow | ||
$ ark-cli file append . tags 22-207093268 one_more_time | ||
$ ark-cli storage list . tags --versions=true | ||
id value | ||
22-207093268 search,engine | ||
22-207093268 wow | ||
22-207093268 one_more_time | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http://bing.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http://google.com/ |
Oops, something went wrong.