getting started tutorial
This commit is contained in:
parent
b3403976c4
commit
03bcc05a89
105
README.md
105
README.md
|
@ -5,8 +5,10 @@ Bash script to control OpenRefine via [its HTTP API](https://docs.openrefine.org
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* works with latest OpenRefine version (currently 3.6)
|
* works with latest OpenRefine version (currently 3.6)
|
||||||
* batch processing (import, transform, export)
|
* run batch processes (import, transform, export)
|
||||||
* orcli takes care of starting and stopping OpenRefine with temporary workspaces
|
* orcli takes care of starting and stopping OpenRefine with temporary workspaces
|
||||||
|
* allows execution of arbitrary bash scripts
|
||||||
|
* interactive mode for playing around and debugging
|
||||||
* your existing OpenRefine data will not be touched
|
* your existing OpenRefine data will not be touched
|
||||||
* import CSV, ~~TSV, line-based TXT, fixed-width TXT, JSON or XML~~ (and specify input options)
|
* import CSV, ~~TSV, line-based TXT, fixed-width TXT, JSON or XML~~ (and specify input options)
|
||||||
* supports stdin, multiple files and URLs
|
* supports stdin, multiple files and URLs
|
||||||
|
@ -29,24 +31,101 @@ Bash script to control OpenRefine via [its HTTP API](https://docs.openrefine.org
|
||||||
|
|
||||||
2. Download bash script there and make it executable
|
2. Download bash script there and make it executable
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
wget https://github.com/opencultureconsulting/orcli/raw/main/orcli
|
wget https://github.com/opencultureconsulting/orcli/raw/main/orcli
|
||||||
chmod +x orcli
|
chmod +x orcli
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Optional: Create a symlink in your $PATH (e.g. to ~/.local/bin)
|
Optional:
|
||||||
|
|
||||||
```sh
|
* Create a symlink in your $PATH (e.g. to ~/.local/bin)
|
||||||
ln -s "${PWD}/orcli" ~/.local/bin/
|
|
||||||
```
|
```sh
|
||||||
|
ln -s "${PWD}/orcli" ~/.local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
* Install Bash tab completion
|
||||||
|
|
||||||
|
* temporary
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source <(orcli completions)
|
||||||
|
```
|
||||||
|
|
||||||
|
* permanently
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mkdir -p ~/.bashrc.d
|
||||||
|
orcli completions > ~/.bashrc.d/orcli
|
||||||
|
```
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
1. Launch an interactive playground
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./orcli run --interactive
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Create OpenRefine project `duplicates` from comma-separated-values (CSV) file
|
||||||
|
|
||||||
|
```sh
|
||||||
|
orcli import csv "https://git.io/fj5hF" --projectName "duplicates"
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Show OpenRefine project's metadata
|
||||||
|
|
||||||
|
```sh
|
||||||
|
orcli info "duplicates"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. ~~~Remove duplicates~~~
|
||||||
|
|
||||||
|
5. Export data from OpenRefine project to tab-separated-values (TSV) file `duplicates.tsv`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
orcli export tsv "duplicates" --output "duplicates.tsv"
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Write out your session history to file `example.sh` (and delete the last line to remove the history command)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
history -a "example.sh"
|
||||||
|
sed -i '$ d' example.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
7. Exit playground
|
||||||
|
|
||||||
|
```sh
|
||||||
|
exit
|
||||||
|
```
|
||||||
|
|
||||||
|
8. Run batch process
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./orcli run example.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
9. Cleanup example files
|
||||||
|
|
||||||
|
```sh
|
||||||
|
rm duplicates.tsv
|
||||||
|
rm`example.sh
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use integrated help screens for available options and examples for each command.
|
* Use integrated help screens for available options and examples for each command.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
orcli --help
|
orcli --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* If your OpenRefine is running on a server, then use the environment variable OPENREFINE_URL.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
OPENREFINE_URL="http://localhost:3333" orcli list
|
||||||
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|
18
orcli
18
orcli
|
@ -35,10 +35,10 @@ orcli_usage() {
|
||||||
# :command.usage_commands
|
# :command.usage_commands
|
||||||
printf "Commands:\n"
|
printf "Commands:\n"
|
||||||
echo " completions Generate bash completions"
|
echo " completions Generate bash completions"
|
||||||
echo " import import commands"
|
echo " import commands to create OpenRefine projects from files or URLs"
|
||||||
echo " list list projects on OpenRefine server"
|
echo " list list projects on OpenRefine server"
|
||||||
echo " info show project metadata"
|
echo " info show OpenRefine project's metadata"
|
||||||
echo " export export commands"
|
echo " export commands to export data from OpenRefine projects to files"
|
||||||
echo " run run tmp OpenRefine workspace and execute shell script(s)"
|
echo " run run tmp OpenRefine workspace and execute shell script(s)"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
@ -122,11 +122,11 @@ orcli_completions_usage() {
|
||||||
# :command.usage
|
# :command.usage
|
||||||
orcli_import_usage() {
|
orcli_import_usage() {
|
||||||
if [[ -n $long_usage ]]; then
|
if [[ -n $long_usage ]]; then
|
||||||
printf "orcli import - import commands\n"
|
printf "orcli import - commands to create OpenRefine projects from files or URLs\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
else
|
else
|
||||||
printf "orcli import - import commands\n"
|
printf "orcli import - commands to create OpenRefine projects from files or URLs\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -253,11 +253,11 @@ orcli_list_usage() {
|
||||||
# :command.usage
|
# :command.usage
|
||||||
orcli_info_usage() {
|
orcli_info_usage() {
|
||||||
if [[ -n $long_usage ]]; then
|
if [[ -n $long_usage ]]; then
|
||||||
printf "orcli info - show project metadata\n"
|
printf "orcli info - show OpenRefine project's metadata\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
else
|
else
|
||||||
printf "orcli info - show project metadata\n"
|
printf "orcli info - show OpenRefine project's metadata\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -296,11 +296,11 @@ orcli_info_usage() {
|
||||||
# :command.usage
|
# :command.usage
|
||||||
orcli_export_usage() {
|
orcli_export_usage() {
|
||||||
if [[ -n $long_usage ]]; then
|
if [[ -n $long_usage ]]; then
|
||||||
printf "orcli export - export commands\n"
|
printf "orcli export - commands to export data from OpenRefine projects to files\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
else
|
else
|
||||||
printf "orcli export - export commands\n"
|
printf "orcli export - commands to export data from OpenRefine projects to files\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -38,7 +38,7 @@ commands:
|
||||||
Usage: eval "\$(orcli completions)"
|
Usage: eval "\$(orcli completions)"
|
||||||
|
|
||||||
- name: import
|
- name: import
|
||||||
help: import commands
|
help: commands to create OpenRefine projects from files or URLs
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
- name: csv
|
- name: csv
|
||||||
|
@ -77,7 +77,7 @@ commands:
|
||||||
help: list projects on OpenRefine server
|
help: list projects on OpenRefine server
|
||||||
|
|
||||||
- name: info
|
- name: info
|
||||||
help: show project metadata
|
help: show OpenRefine project's metadata
|
||||||
args:
|
args:
|
||||||
- name: project
|
- name: project
|
||||||
help: project name or id
|
help: project name or id
|
||||||
|
@ -87,7 +87,7 @@ commands:
|
||||||
- info 1234567890123
|
- info 1234567890123
|
||||||
|
|
||||||
- name: export
|
- name: export
|
||||||
help: export commands
|
help: commands to export data from OpenRefine projects to files
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
- name: tsv
|
- name: tsv
|
||||||
|
|
Loading…
Reference in New Issue