A command line client and C++ library that uses the Autolab REST API.
This C++ project has the following dependencies:
CMake is already setup to automatically handle acquiring and setting up rapidjson.
Please make sure openssl and libcurl libraries are installed prior to building. They can usually be installed with the system's package manager on Linux.
For example, on Ubuntu, users can install these dependencies by running:
sudo apt-get install libssl-dev libcurl4-openssl-dev
The program requires client credentials in order to build.
First, register a new application on your deployment of Autolab. Go to 'Manage Autolab' and click on 'Manage API Applications.' Click on 'New Application'
Then in 'New Application,' specify a name, and the redirect_uri. The redirect_uri should be '<host>/device_flow_auth_cb' since this application uses the 'device_flow' authorization method, where '' is the your Autolab domain. For example, for Nightly, use 'https://nightly.autolabproject.com/device_flow_auth_cb'.
The scopes should be user_info user_courses user_scores user_submit
. To test building without credentials, use empty strings as credentials and continue.
Then, create file src/app_credentials.h by making a copy of src/app_credentials.h.template, and enter the generated client_id and client_secret into the predefined fields in the file, as well as the Autolab server domain and redirect_uri (same as the one entered into the Autolab Oauth2 manager).
You should then after building autolab-cli, be able to run autolab setup
, and successfully authorize the CLI with your Autolab deployment.
This project uses CMake. On Linux, it generates Makefiles for the project, which can then be used by the make
command to perform regular incremental builds.
We've written an install script that builds the entire project, installs the binary to your system, and installs the bash autocompletion script. You can run it by executing ./install/install.sh
. It needs sudo access in order to copy files to protected directories (details below)
- create 'build' directory under project root directory.
- cd into 'build', run
cmake ..
. - inside 'build', run
make
.
This will build two targets:
- An executable build/src/autolab
- A static library build/lib/autolab/libautolab.a
You can optionally run sudo make install
to install the built binaries (typically to /usr/local/bin/
).
After installing manually, users can cd out of build and execute the following commands:
sudo cp autocomplete/autolab /etc/bash_completion.d/
. /etc/bash_completion.d/autolab
This will move our autocompletion script out of a local folder and into the bash autocompletion directory. To learn more about bash autocompletion, see https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_2
There are two kinds of builds available: release and non-release. Release builds do not contain debug output (output that use Logger::debug).
The default is non-release builds. To build a release version, when inside the 'build' directory, run cmake -Drelease=ON ..
(note the periods at the end), then run make
.
In addition to specifying the version number in CMakeLists.txt, a 'build variant' string can be used to include metadata about the build. This info will be shown when running autolab --version
.
For example, in our official build for the CMU shark machines, we run cmake with -Dvariant=cmu-shark
. This helps indicate what the executable was built for.
Run 'autolab -h' to find out the commands available.
To use the autolab client library in your own C++ program, include the header files in include/autolab/, then link against libautolab.a. Make sure you are compiling with at least C++11.