The Google Drive Push CLI is a tool for syncing files between a local directory and Google Drive. It supports pushing and pulling files, managing remote items, and displaying differences between local and remote files.
Before you can use the tool, you'll need to enable the Google Drive API and set up OAuth 2.0 credentials. Follow these steps to set it up:
- Go to the Google Cloud Console.
- Create a new project.
- Enable the Google Drive API for your project:
- Navigate to APIs & Services > Library.
- Search for "Google Drive API" and enable it.
- Create OAuth 2.0 credentials:
- Go to APIs & Services > Credentials.
- Click Create Credentials > OAuth Client ID.
- Choose Desktop App as the application type.
- Download the
credentials.jsonfile and save it to the configuration directory:- Linux:
/home/<user>/.config/goop - Windows:
C:\Users\<user>\AppData\Roaming\goop
- Linux:
To install or update the Google Drive Push CLI, run:
curl -L -o /tmp/goop https://github.com/yojoecapital/goop-cli/releases/latest/download/goop && chmod 755 /tmp/goop && sudo mv /tmp/goop /usr/local/bin/Run the following command to see all available options and commands:
goop --help-
initialize <remote-path>(orinit): set up a new sync folder by creating a.goopfile in the current directory- use
--depth <depth>to set the maximum folder depth to sync - if the
<remote-path>argument is omitted, an interactive prompt will allow users to traverse their Google Drive directories in the terminal and select the folder to sync
- use
-
push: upload local changes to the associated Google Drive folder- use
--operations [c|u|d](or-x) to specify which operations should be pushed. Thecstands for create,ufor update, anddfor delete. The default value for this iscudfor all the operations - use
--ignore <glob-pattern>(or-i) to ignore additional glob patterns from being processed
- use
-
pull: download remote changes from Google Drive to the local directory- the same arguments in
pushare present inpull
- the same arguments in
-
diff: display the differences between the last modified times of local and remote files
You can manage remote items with the remote command. If you omit the <path> argument, an interactive prompt will be used instead.
remote info <path>(orremote information): get information for a remote itemremote list <path>(orremote ls): list items in a remote folder (default is/)remote mkdir <path>: create a new folder in an existing remote folderremote move <path>(orremote mv): move or reparent an itemremote trash <path>: move an item to the trashremote download <path>: download a remote item
The program stores a cache under ~/.config/goop-cli/cache.db, which can be deleted to clear the cache. Additionally, there are configuration options in ~/.config/goop-cli/config.json.
Here is an example of the configuration file:
{
"cache": {
"ttl": 300000, // Cache TTL in milliseconds
"enabled": true
},
"auth": {
"max_token_retries": 3, // The max number of times to retry token refreshes
"retry_delay": 1000 // The delay in milliseconds between token refreshes
},
"auto_ignore_list": [ // Files to ignore during sync
".goop",
".goopignore"
],
"default_depth": 3, // Default sync folder depth
"max_depth": 3, // Maximum sync folder depth
}Create a .goopignore file inside a sync folder and use it specify a list of glob patterns that should be ignored.
secret-file.txt
secret-items/**
To compile and build the project as a self-contained executable:
cd GoogleDrivePushCli
dotnet publish -c Release -r linux-x64 --self-contained true /p:PublishSingleFile=trueReplace linux-x64 with the appropriate target platform (e.g. win-x64).