Skip to content

Repository files navigation

DriveCLI

A cross-platform Google Drive CLI built with .NET 9 and Spectre.Console.

Features

  • OAuth 2.0 Login — Browser-based or manual code-paste authentication with token caching
  • Headless / SSH Support — Auto-detects headless environments; manual login via --manual flag
  • Browse & Search — List files, navigate folders, search by name or MIME type
  • Resumable Transfers — Upload/download with progress bars, speed display, and MD5 verification
  • Recursive Folder Upload/Download — Mirror entire directory trees
  • File Management — Move, rename, trash/delete, and share files
  • Rich Terminal UX — Tables, progress bars, and colour via Spectre.Console
  • Cross-Platform — Runs on Windows, Linux, and macOS (single self-contained binary)

Prerequisites

  • .NET 9 SDK (for building from source)
  • A Google Cloud project with the Drive API enabled
  • An OAuth 2.0 Desktop client credential (Client ID + Client Secret)

Setup

  1. Clone the repository

    git clone https://github.com/bishojit/DriveCLI.git
    cd DriveCLI
  2. Build

    dotnet build
  3. Login

    # Interactive login (prompts for Client ID & Secret at runtime)
    dotnet run -- login
    
    # Manual code-paste flow (for headless / SSH servers)
    dotnet run -- login --manual
    
    # Or use a pre-placed credentials.json file
    dotnet run -- login --file

    The interactive login will ask:

    • Client ID — from Google Cloud Console
    • Client Secret — masked input
    • Save login credentials for future use? — Yes/No (default: No)

    If you choose Yes, credentials are saved locally so subsequent commands skip the prompt.

    Headless / SSH: On servers without a browser, DriveCLI auto-detects the environment and falls back to the manual flow (prints a URL, you paste the authorization code). You can also force this with --manual / -m.

Commands

Command Description
drivecli login Interactive login (prompts for Client ID/Secret)
drivecli login --manual Manual code-paste flow (headless / SSH)
drivecli login --file Login using pre-placed credentials.json
drivecli logout Revoke and delete cached credentials
drivecli ls [folder-id] List files (root or specified folder)
drivecli find <query> [--type <mime>] Search files by name
drivecli upload <path> [--parent <id>] [--recursive] Upload file or folder
drivecli download <id> [--output <path>] [--recursive] Download file or folder
drivecli rm <id> [--permanent] [--yes] Trash or permanently delete
drivecli mv <id> <folder-id> Move file to another folder
drivecli rename <id> <new-name> Rename a file or folder
drivecli share <id> [--role <role>] [--type <type>] Generate a shareable link
drivecli ps List all background transfers
drivecli ps <transfer-id> Inspect a specific transfer
drivecli ps-stop <transfer-id> Stop a running background transfer

Examples

# Authenticate (interactive — prompts for Client ID & Secret)
drivecli login

# Authenticate on headless / SSH server (manual code-paste)
drivecli login --manual

# Authenticate with saved credentials.json
drivecli login --file

# List root files
drivecli ls

# List a specific folder
drivecli ls 1A2B3C4D5E

# Search for PDFs
drivecli find "report" --type application/pdf

# Upload a file
drivecli upload ./my-file.zip

# Upload a folder recursively to a target folder
drivecli upload ./my-folder --recursive --parent 1A2B3C4D5E

# Download a file
drivecli download 1A2B3C4D5E

# Download a folder
drivecli download 1A2B3C4D5E --recursive --output ./downloads

# Move a file
drivecli mv FILE_ID TARGET_FOLDER_ID

# Rename a file
drivecli rename FILE_ID "new-name.txt"

# Share a file (public read link)
drivecli share FILE_ID

# Permanently delete (with confirmation skip)
drivecli rm FILE_ID --permanent --yes

# List background transfers
drivecli ps

# Inspect a specific transfer
drivecli ps aae34

# Stop a background transfer
drivecli ps-stop aae34

# Log out
drivecli logout

Publishing

See docs/06-building-from-source.md for detailed build and publish instructions.

Quick single-file build (cross-platform from any OS):

Target Command
Linux x64 dotnet publish -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
Windows x64 dotnet publish -c Release -r win-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
macOS x64 dotnet publish -c Release -r osx-x64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
macOS ARM dotnet publish -c Release -r osx-arm64 --self-contained -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true

Project Structure

DriveCLI/
├── Program.cs                  # Entry point & command registration
├── Commands/                   # CLI command implementations
│   ├── LoginCommand.cs
│   ├── LogoutCommand.cs
│   ├── ListCommand.cs
│   ├── FindCommand.cs
│   ├── UploadCommand.cs
│   ├── DownloadCommand.cs
│   ├── BgUploadCommand.cs
│   ├── BgDownloadCommand.cs
│   ├── RemoveCommand.cs
│   ├── MoveCommand.cs
│   ├── RenameCommand.cs
│   ├── PsCommand.cs
│   └── ShareCommand.cs
├── Services/                   # Business logic
│   ├── AuthService.cs
│   ├── DriveService.cs
│   ├── TransferService.cs
│   └── ShareService.cs
├── Models/
│   ├── DriveItem.cs
│   └── TransferProgress.cs
├── Helpers/
│   ├── PathHelper.cs
│   ├── ConsoleRenderer.cs
│   └── TransferMonitor.cs
├── docs/                       # Documentation
├── DriveCLI.csproj
├── DriveCLI.sln
├── .gitignore
└── README.md

📄 License

MIT License - see the LICENSE file for details.

👨‍💻 Author

Developed by Bikiran


Made with ❤️ for the .NET community

⭐ Star this repo🐛 Report Bug💡 Request Feature


🏢 About Bikiran

Bikiran is a software development and cloud infrastructure company founded in 2012, headquartered in Khulna, Bangladesh. With 15,000+ clients and over a decade of experience, Bikiran builds and operates a suite of products spanning domain services, cloud hosting, app deployment, workflow automation, and developer tools.

SL Topic Product Description
1 Website Bikiran Main platform — Domain, hosting & cloud services
2 Website Edusoft Education management software for institutions
3 Website n8n Clouds Managed n8n workflow automation hosting
4 Website Timestamp Zone Unix timestamp converter & timezone tool
5 Website PDFpi Online PDF processing & manipulation tool
6 Website Blog Technical articles, guides & tutorials
7 Website Support 24/7 customer support portal
8 Website Probackup Automated database backup for SQL, PostgreSQL & MongoDB
9 Service Domain Domain registration, transfer & DNS management
10 Service Hosting Web, app & email hosting on NVMe SSD
11 Service Email & SMS Bulk email & SMS notification service
12 npm Chronopick Date & time picker React component
13 npm Rich Editor WYSIWYG rich text editor for React
14 npm Button Reusable React button component library
15 npm Electron Boilerplate CLI to scaffold Electron.js project templates
16 NuGet Bkash bKash payment gateway integration for .NET
17 NuGet Bikiran Engine Core .NET engine library for Bikiran services
18 Open Source PDFpi PDF processing tool — open source
19 Open Source Bikiran Engine Core .NET engine — open source
20 Open Source Drive CLI CLI tool to manage Google Drive from terminal
21 Docker Pgsql Docker setup for PostgreSQL
22 Docker n8n Docker setup for n8n automation
23 Docker Pgadmin Docker setup for pgAdmin
24 Social Media LinkedIn Bikiran on LinkedIn
25 Social Media Facebook Bikiran on Facebook
26 Social Media YouTube Bikiran on YouTube
27 Social Media FB n8nClouds n8n Clouds on Facebook

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages