An open API service indexing awesome lists of open source software.

https://github.com/abdo-omran2206/gofilecli

The missing command-line companion for GoFile.io. Upload files, manage your account, and track your history straight from the terminal.
https://github.com/abdo-omran2206/gofilecli

cli command-line-tool file-sharing file-upload gofile python python3 rich-cli sqlite3 terminal-app

Last synced: 9 days ago
JSON representation

The missing command-line companion for GoFile.io. Upload files, manage your account, and track your history straight from the terminal.

Awesome Lists containing this project

README

          


GoFileCLI Logo

GoFileCLI


The missing command-line companion for GoFile.io



Python
GoFile
Contributions Welcome


---

## Features

- 📤 Upload single files or entire folders to GoFile.io
- 📊 Real-time upload progress bar with speed and ETA
- 🗃️ Upload history stored in a local SQLite database
- 📋 Copy download links to clipboard instantly
- 🔑 API token management (set / remove / view)
- ⚙️ Configurable auto-save and account status settings
- 🖥️ Interactive TUI menu **and** scriptable CLI commands

---

## Project Structure

```
GoFile/
├── main.py # Entry point — launches CLI or interactive GUI
├── requirements.txt
├── .env # Auto-created; stores API_TOKEN, ACCOUNT_STATUS, AUTO_SAVE

├── cli/
│ ├── parser.py # argparse definitions for all CLI subcommands
│ └── commands.py # Handler functions wired to each subcommand

├── lib/
│ ├── Gofile.py # GoFile API client (upload file / folder)
│ ├── config.py # .env read/write (token, status, auto-save)
│ └── db.py # SQLite history database

├── screens/
│ ├── upload_menu.py # Interactive upload screen
│ ├── history_menu.py # Interactive history browser
│ ├── account_menu.py # Interactive login / logout screen
│ └── settings_menu.py # Interactive settings screen

└── utils/
└── ui.py # Colors, clear(), copy_link(), format_size(),
# ProgressFile, upload_progress_bar()
```

---

## Installation

```bash
git clone https://github.com/Abdo-omran2206/Gofilecli.git
cd Gofilecli
pip install -r requirements.txt
```

**Dependencies:**

| Package | Version |
|---|---|
| `requests` | >= 2.25.1 |
| `art` | >= 5.9 |
| `rich` | >= 13.0 |
| `pyperclip` | >= 1.8 |
| `python-dotenv` | >= 1.0.0 |
| `prompt_toolkit` | (used by upload screen) |

---

## Usage

### Interactive Mode

Running without any subcommand launches the interactive TUI:

```bash
python main.py
```

Menu options:
1. **Upload File** — Enter a file/folder path with tab-completion
2. **View History** — Browse past uploads in a Rich table, view details, copy links, delete entries
3. **Account** — Login (set token) or Logout (remove token)
4. **Settings** — Toggle auto-save, toggle account status, clear history
5. **Exit**

---

### CLI Mode

All commands follow the pattern:

```bash
python main.py [options]
```

#### `version` — Show application version

```bash
python main.py version
```

---

#### `upload` — Upload multiple files or folders

```bash
python main.py upload [FILE_PATH ...] [--no-save]
```

| Argument | Description |
|---|---|
| `FILE_PATH` | One or more space-separated paths to files **or** directories to upload |
| `--no-save` | Skip saving the upload records to the local history database |

**Examples:**
```bash
# Upload a single file
python main.py upload "C:\Users\Me\Documents\report.pdf"

# Upload multiple files and folders at once
python main.py upload "C:\Users\Me\photo.jpg" "C:\Users\Me\Documents\report.pdf" "C:\Users\Me\MyFolder"

# Upload without saving to history
python main.py upload "C:\Users\Me\photo.jpg" --no-save
```

> **Note:** Folder uploads require an **active** account status and a valid API token.

---

#### `history` — View or manage upload history

```bash
python main.py history [--show ID] [--delete ID] [--clear]
```

| Option | Description |
|---|---|
| *(no options)* | Open the interactive history browser |
| `--show ID` | Print full details of the history entry with the given ID |
| `--delete ID` | Delete the history entry with the given ID |
| `--clear` | Delete **all** history entries |

**Examples:**
```bash
python main.py history # Interactive browser
python main.py history --show 5 # Show details for entry #5
python main.py history --delete 5 # Delete entry #5
python main.py history --clear # Wipe all history
```

---

#### `token` — Manage your GoFile API token

```bash
python main.py token [--set API_TOKEN] [--remove]
```

| Option | Description |
|---|---|
| *(no options)* | Display the currently stored token |
| `--set API_TOKEN` | Save a new API token and set account status to `active` |
| `--remove` | Remove the stored token and set account status to `guest` |

**Examples:**
```bash
python main.py token # Show current token
python main.py token --set abc123xyz # Set a new token
python main.py token --remove # Remove token / logout
```

---

#### `config` — Manage configuration settings

```bash
python main.py config [--toggle-autosave] [--get-autosave]
[--toggle-account-status] [--get-account-status]
```

| Option | Description |
|---|---|
| `--toggle-autosave` | Switch auto-save history between ON and OFF |
| `--get-autosave` | Show current auto-save setting |
| `--toggle-account-status` | Switch account status between `active` and `guest` |
| `--get-account-status` | Show current account status |

**Examples:**
```bash
python main.py config --get-autosave
python main.py config --toggle-autosave
python main.py config --get-account-status
python main.py config --toggle-account-status
```

---

## Configuration

Settings are stored in a `.env` file (auto-created on first run):

| Key | Default | Description |
|---|---|---|
| `API_TOKEN` | *(empty)* | Your GoFile API token |
| `ACCOUNT_STATUS` | `guest` | `guest` or `active` |
| `AUTO_SAVE` | `true` | Whether to save uploads to history automatically |

---

## How It Works

1. **Server selection** — The client calls `GET /servers` to pick the best available GoFile server before each upload.
2. **File upload** — Files are streamed via `multipart/form-data` POST with a live Rich progress bar showing bytes transferred, speed, and ETA.
3. **Folder upload** — The first file in the folder is uploaded to create a GoFile folder; subsequent files are uploaded into the same folder using the returned `parentFolder` ID.
4. **History** — On successful upload, metadata (file name, original path, GoFile folder ID, download link, size, MIME type, timestamp) is stored in `data/gofilecli.db`.

---

## Author

Made by [AkiraOmran](https://github.com/Abdo-omran2206)