Flywheel CLI Usage and Examples
This document provides information on CLI usage and Examples.
Basic Setup
Check Version
To check the currently-installed version of the Flywheel CLI, run the fw version
command:
Login
Before using any commands, you will need to use your API key to login to your instance of Flywheel:
Where <redacted>
is substituted with your real API Key. Do not share your key with anybody else!
Security Tip
Everything entered on the command line is recorded in a history file on your computer in plain text -- this may include your API key if you enter it in-line with fw login <api-key>
!
To prevent your API key from being stored in your command history, you may choose to store your API key in a text file instead. To do this, create a new text file (e.g., fw-api-key.txt
) and place only your API key in it. Then, you can pipe it the contents of the file into the fw login
command using xargs
like so:
cat /path/to/fw-api-key.txt | xargs fw login
With this approach, your API key is still stored in clear text on your local computer, but it is at least only stored in a single place (the text file you created) instead of potentially being copied multiple times throughout your command history.
For even better security, consider encrypting your credentials file using using a tool like SOPS or by migrating to password manager like 1Password.
Getting Help
Try running fw
without any arguments (with or without -h
) to get a feel for what commands are available.
You can append -h
or --help
to any command to get more information. For example, using the -h
option with the fw download
command will show:
Managing Data
Viewing
We can start with fw ls
to explore the Flywheel hierarchy and locate data:
This lists the groups available to you, alongside your current permission level. For example, this user is an admin
in each of these three groups: neuroscience
, clinical
, and psychology
Tip
Site Admin users can access all groups and projects (similar to Manage Site mode in the Web UI) by adding the -a
or --all
flag to the CLI command.
You can fw ls
further into the hierarchy, much as you would with your system ls
command:
This shows projects and then sessions. For sessions, you can see the timestamp and subject code. The last entry is an attachment on the project.
Downloading
You can download a file with fw download
in much the same way you use fw ls
:
You can also download a project, session, or acquisition:
Uploading
To upload a file, enter the name of the container in Flywheel and the path to the file on your local computer:
You can then see the file in by running fw ls
:
Learn More
There are many more commands available in the CLI, particularly for interacting with large volumes of data of various formats. More information about each command can found in the Command References documentation folder.