In order to provide those 2 modes, it features one server (**MEGAcmdServer**), an interactive shell (**MEGAcmdShell**) and several commands that will launch the non-interactive client (**MEGAcmdClient**).
All dependencies are downloaded and installed automatically by vcpkg while building. The local path to the vcpkg repository can be set with the `-DVCPKG_ROOT` flag (defaults to `../vcpkg` if the flag is missing).
A different build type can be selected out of `Debug`, `Release`, `MinSizeRel`, or `RelWithDebInfo`. By convention, we use `build/build-cmake-[Debug|Release|...]` as build directory, but any other path can be selected with the `-B` option.
On Unix-based systems, such as Linux or macOS, MEGAcmd can be installed with (after building):
```
sudo cmake --install build/build-cmake-Release
```
This will install `mega-cmd`, `mega-cmd-server`, and all `mega-*` commands such as `mega-put`, `mega-cd`, etc. It is recommended to avoid installing a Debug build, since some paths might not be properly setup.
Before explaining the two ways of interaction, it's important to understand how MEGAcmd works. When you login with MEGAcmd, your session, the list of synced folders, cache databases, and extra configuration are stored in your local home folder. Closing it does not delete those, and restarting the MEGAcmd server will restore your previous session (similary to the MEGA Desktop App, which won't ask for user/password once restarted).
Now let's get into details of the two usage modes. Both modes require that MEGAcmdServer is running. You can manually launch it. Fortunately, you can also open the interactive shell or execute any command and the server will start automatically.
Execute MEGAcmd shell. [`Platform`](#platforms) section explains how to do that in the different supported systems. You should be facing an interactive shell where you can start typing your commands, with their arguments and flags.
First you would like to log in into your account. Again, notice that doing this stores the session and other stuff in your home folder. A complete logout is required if you want to end you session permanently and clean any traces (see `logout --help` for further info).
`mega-help` will list all these commands (you will need to prepend "mega-" to the commands listed there). To obtain further info use `mega-command --help`.
Or have it built without `--prefix`, both the server (`mega-cmd-server`), the shell (`mega-cmd`) and the different client commands (`mega-*`) will be in your `PATH` (on a fresh install, you might need to open your terminal again).
If you are interested in installing MEGAcmd without human intervention, notice that this installer supports silent installation, you just need to execute in your command prompt:
Once you have MEGAcmd installed, you just need to execute it (via Desktop icon or Start Menu) to open the shell. This will open MEGAcmdServer in the background (a process named MEGAcmdServer.exe).
For macOS, after installing the dmg, you can launch the server using MEGAcmd in Applications. If you wish to use the client commands from macOS Terminal, open the Terminal and include the installation folder in the `PATH`.
*Note for macOS Catalina or above*: since Catalina, macOS uses `zsh` as default shell. If you want to have auto completion, we strongly recommend you to use `bash` shell (just execute `bash` in your terminal).
Currently we have build scripts for **Synology**, which can be found in the `build/SynologyNAS` folder along with instructions on how to set up the build. Typically this results in a 'package' which can then be manually installed in the NAS. To use MEGAcmd on those systems, ssh into the device and run the commands as normal (having first added their folder to your `PATH` variable).
MEGAcmd features autocompletion in both interactive and non-interactive (only for bash) mode. It will help completing both local and remote (Mega Cloud) files, flags for commands, values for flags/access levels, even contacts.
If you have compiled MEGAcmd with PCRE (enabled by default), you can use PCRE compatible expressions in certain commands with the flag `--use-pcre`. Otherwise, if compiled with c++11, c++11 regular expressions will be used.
**Notice:** if you use MEGAcmd in non interactive mode, notice that shell pattern will take precedence. You will need to either escape symbols like `*` (`\*`) or surround them between quotes (e.g: "*.txt").
For Linux, whenever there is a new update, it will be published in the corresponding repository and your system's updating tool will let you update it.
You can also update manually by typing `update` within MEGAcmd. This will check if there are updates available and proceed to update if affirmative. Whenever MEGAcmd is updated it will be restarted (all open instances of MEGAcmdShell will be restarted too).