https://github.com/doneill/er-cli
EarthRanger Command Line Interface
https://github.com/doneill/er-cli
Last synced: 6 days ago
JSON representation
EarthRanger Command Line Interface
- Host: GitHub
- URL: https://github.com/doneill/er-cli
- Owner: doneill
- License: apache-2.0
- Created: 2023-11-18T01:09:28.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2025-01-16T05:51:51.000Z (11 months ago)
- Last Synced: 2025-03-20T07:16:24.230Z (9 months ago)
- Language: Go
- Homepage:
- Size: 115 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EarthRanger CLI

## Build
`go build -o bin/er`
## Help
```bash
Work with EarthRanger platform from command line
Usage:
er [command]
Available Commands:
auth Authentication with EarthRanger
completion Generate the autocompletion script for the specified shell
help Help about any command
open Open a SQLite database file
user Current authenticated user data
Flags:
-h, --help help for er
-t, --toggle Help message for toggle
-v, --version version for er
Use "er [command] --help" for more information about a command.
```
## Remote Site Server Commands
These commands allow you to work through an authenticated user account with your EarthRanger site server.
### Authenticate
```bash
er auth [flags]
er auth [command]
Available commands
token Display token
Flags:
-s, --sitename string EarthRanger site name
-u, --username string EarthRanger username
```
**Examples:**
```bash
# Authenticate a user and sitename
er auth -s {sitename} -u {username}
# Display token once authenticated
er auth token
```
### User Details
```bash
# Display the currently authenticated user
er user
# Returns table data
| USERNAME | EMAIL | FIRST NAME | LAST NAME | ID | PIN | SUBJECT ID |
|----------|----------------------|------------|-----------|--------------------------------------|------|--------------------------------------|
| cccy | | CC | CY | 015945ff-c220-4674-a070-3f1112e445fg | | 12c245f6-8d77-4e15-a82c-be4a717034df |
```
## Local Database Commands
These commands allow you to work with an exported EarthRanger mobile databse
```bash
This tool is intended to be used specficially with EarthRanger mobile databases
Usage:
er open [sqlite db file] [flags]
Flags:
-e, --events Display all pending sync events
-h, --help help for open
-t, --tables Display all database tables
-u, --user Display database account user
```
### Open
Open an EarthRanger database file. This command is the entry to working with the database
```bash
er open earthranger.db
earthranger.db successfully opened!
```
### Tables
Display all tables and record count
```bash
er open earthranger.db -t
+------------------+-------+
| NAME | COUNT |
+------------------+-------+
| android_metadata | 1 |
| accounts_user | 1 |
| sqlite_sequence | 9 |
| user_profiles | 2 |
| user_subjects | 3 |
| event_type | 51 |
| event_category | 5 |
| events | 13 |
| attachments | 17 |
| sync_states | 5 |
| patrol_types | 4 |
| patrols | 0 |
| patrol_segments | 0 |
+------------------+-------+
```
### Events
Display all pending sync events
```bash
er open earthranger.db -e
+----+--------------+--------------------+-----------------------------------+-------------------+--------------------------+
| ID | USER | TITLE | VALUES | PATROL SEGMENT ID | CREATED AT |
+----+--------------+--------------------+-----------------------------------+-------------------+--------------------------+
| 9 | dai3-profile | Light | {"lightrep_whatdetected":"torch"} | 1 | 2023-11-09T09:00:21.487Z |
| 13 | dai2-profile | String No Required | {"string":"Ggg"} | 2 | 2023-11-13T16:04:31.574Z |
+----+--------------+--------------------+-----------------------------------+-------------------+--------------------------+
```
### Database user
Query the database for the username of the mobile user
```bash
er open earthranger.db -u
username
```
## Licensing
A copy of the license is available in the repository's [LICENSE](LICENSE) file.