Command-Line Interface#
sadrive#
sadrive [OPTIONS] COMMAND [ARGS]...
clearall#
CLI command to permanently delete all files across all service accounts and reset the local file and size maps.
- Side Effects:
Deletes every non-trashed file owned by each service account.
Clears the file_map table.
Resets all service account sizes to zero.
Prints progress and a final confirmation message.
sadrive clearall [OPTIONS]
config#
Top-level configuration command group.
Use this group to manage application settings, such as the config directory location.
sadrive config [OPTIONS] COMMAND [ARGS]...
set-dir#
Sets and remembers the configuration directory.
- Args:
- path: Filesystem path to use as the config directory.
Will be created if it does not exist.
- Side Effects:
Creates the directory (including parents) if missing.
Writes the resolved path to CONFIG_POINTER file.
Prints a confirmation message.
sadrive config set-dir [OPTIONS] PATH
Arguments
- PATH#
Required argument
show#
Shows the currently configured directory.
- Prints:
The path previously set by set_dir.
- Raises:
RuntimeError: If no config directory has been set.
sadrive config show [OPTIONS]
delete#
CLI command to delete a file or folder by its ID.
If the ID corresponds to a folder, deletion is recursive.
- Args:
fileid: The Drive ID of the file or folder.
- Side Effects:
Removes the file/folder from Google Drive.
Updates the local database to reflect deletion.
Prints status messages to the console.
sadrive delete [OPTIONS] FILEID
Arguments
- FILEID#
Required argument
details#
Display storage usage details for all service accounts.
Prints a table with occupied and free space per account.
sadrive details [OPTIONS]
download#
Downloads a folder from the ‘sadrive’ remote by its ID.
Uses the gclone executable configured via config to perform a multi-threaded copy with progress display.
- Args:
id: The Drive folder ID to copy from the remote. dest: Local destination directory path. –transfers: Number of parallel transfer threads (default 8).
- Side Effects:
Invokes the gclone subprocess with constructed arguments.
Prints success or error messages on completion.
sadrive download [OPTIONS] ID DEST
Options
- -t, --transfers <transfers>#
Number of concurrent transfers
- Default:
8
Arguments
- ID#
Required argument
- DEST#
Required argument
mount#
Mount the SA-Drive remote locally using the gclone tool.
Detects the assigned drive letter, opens Explorer, and keeps the mount until user interrupts (Ctrl+C).
- Side Effects:
Runs ‘gclone mount’ subprocess with vfs caching options.
Streams stderr to console to detect mount point.
Opens a file browser at the mounted drive letter.
Terminates on user interrupt.
sadrive mount [OPTIONS]
newfolder#
Create a folder in SA-Drive at the given destination ID.
- Args:
name: Name of the new folder to create. destination: Drive folder ID under which to create (default: root).
- Side Effects:
Calls Drive API to create the folder.
Inserts the folder record into local DB.
Prints the new folder ID.
sadrive newfolder [OPTIONS] NAME [DESTINATION]
Arguments
- NAME#
Required argument
- DESTINATION#
Optional argument
open-link#
Open the given file or folder ID in the default web browser.
- Args:
id: Drive item ID.
- Side Effects:
Launches browser to the Drive open URL.
sadrive open-link [OPTIONS] ID
Arguments
- ID#
Required argument
rebuild#
Rebuilds a file split into “.sapart” parts based on a manifest.
- Args:
- path: Filesystem path to the “.sapart” directory containing part files
and a “.sapart.manifest.json” manifest.
- Raises:
FileNotFoundError: If any expected part file is missing during rebuild.
- Side Effects:
Reads the manifest to obtain original filename and part order.
Concatenates each part into the rebuilt file in the parent directory.
Removes the original “.sapart” directory upon success.
sadrive rebuild [OPTIONS] PATH
Arguments
- PATH#
Required argument
rename#
Rename a Drive file or folder.
- Args:
newname: New name for the item. id: Drive item ID to rename.
- Side Effects:
Calls Drive API to rename.
Updates local DB record.
sadrive rename [OPTIONS] NEWNAME ID
Arguments
- NEWNAME#
Required argument
- ID#
Required argument
search#
Search the SA-Drive for files or folders by name.
- Args:
name: Substring to search for. fuzzy: If True, use Drive API fuzzy search; else database LIKE search.
- Side Effects:
Prompts user to select a result interactively.
Opens the selected item in browser via open_link.
sadrive search [OPTIONS] NAME [FUZZY]
Arguments
- NAME#
Required argument
- FUZZY#
Optional argument
update-sas#
Synchronize service account usage with the database.
Scans the local accounts directory and the database to find any service accounts not yet recorded and adds them with zero usage. Then, for all accounts in the database, concurrently fetches the actual used storage from Google Drive and updates the size map in sync mode (overwriting previous values).
- Side Effects:
Inserts missing service accounts into sa_size_map via dbf.insert_size_map.
Updates each service account’s size field to the Drive API value via dbf.add_size(syncing=True).
Prints status messages to stdout and echoes completion via Click.
sadrive update-sas [OPTIONS]
upload#
Upload a folder or file to SA-Drive at a specified destination folder ID.
- Args:
ctx: Click context for invoking subcommands. path: Local filesystem path to the file or directory to upload. destination: Drive folder ID where the content will be uploaded (default: root).
- Behavior:
Determines if path is a file or directory.
For files larger than single-account capacity, splits into parts and uploads.
For directories, reflects structure on SA-Drive and uploads all contents.
Updates local database mappings and service account usage.
Provides real-time progress via Rich.
sadrive upload [OPTIONS] PATH [DESTINATION]
Arguments
- PATH#
Required argument
- DESTINATION#
Optional argument