This project is my solution to the GitHub User Activity challenge by Roadmap.sh. It demonstrates how to use C++ to build a simple and efficient command-line tool to fetch and display recent GitHub user activity.
- Cross-platform compatibility: I developed and tested the project to ensure it runs smoothly on both Windows and Unix-based systems (Linux/MacOS).
- API Communication: I implemented requests to the GitHub API over HTTPS, exploring how to consume RESTful APIs and parsing JSON responses directly in C++.
- Use of standard libraries:
- The project relies heavily on C++ standard libraries, minimizing external dependencies.
- The only external library used is OpenSSL, to handle secure HTTPS communication.
- Language: C++
- CLI Structure: Input/output handling
- API Client: Request user activity from Github API
- HTTP Client: Standard system library
- HTTPS Connection: OpenSSL
- Development environment: Compatible with Windows and Unix-based systems.
-
For compile:
- Windows: MSVC (Visual Studio Developer Command Prompt)
- Linux: GCC (GNU Compiler Collection)
- OpenSSL library installed
-
For run:
- Internet connection
- Clone the repository:
git clone https://github.com/jmsmarcelo/github-user-activity-cpp.git cd github-user-activity-cpp
- Compile the project:
mkdir build cd build # Linux: g++ -std=c++17 -o github-activity ../src/*.cpp -lssl -lcrypto -lpthread # Windows (Visual Studio Developer Command Prompt): cl /std:c++17 /EHsc /Fe:github-activity.exe ..\src\*.cpp /I"path\to\OpenSSL\include" ws2_32.lib /link /LIBPATH:"path\to\OpenSSL\lib" libssl.lib libcrypto.lib
- Run the application:
# Linux: ./github-activity <username> # Windows: .\github-activity <username>
# Example:
github-activity kamranahmedse
# output:
# - Pushed 2 commits to kamranahmedse/developer-roadmap
# - Created a comment on an issue in kamranahmedse/developer-roadmap
# - Closed a issue in kamranahmedse/developer-roadmap
github-user-activity-cpp/
├─ include/
│ ├─ api_cli.hpp # CLI API declarations to handle user commands and integrate with the service.
│ ├─ ApiService.hpp # Core logic for managing GitHub user activity data.
│ ├─ ApiClient.hpp # Interface for interacting with the GitHub API to fetch user activity.
│ ├─ HttpClient.hpp # Abstraction for HTTP communications, handling requests and responses.
│ └─ HttpException.hpp # Custom exceptions for handling HTTP-related errors gracefully.
└─ src/
├─ main.cpp # Application entry point, initializes and runs the CLI.
├─ api_cli.cpp # Implementation of CLI commands, interfacing with the service layer.
├─ ApiService.cpp # Implementation of logic for processing and managing GitHub user activity.
├─ ApiClient.cpp # Implementation of interactions with the GitHub API.
├─ HttpClient.cpp # HTTP client logic for sending requests and parsing responses.
└─ HttpException.cpp # Implementation of HTTP-specific exception handling.
Contributions are welcome!
To contribute:
- Fork the repository.
- Create a new branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m "add new feature"
- Push to the branch:
git push origin my-new-feature
- Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Created by Jose Marcelo. Feel free to get in touch or explore more of my projects!