cli: Met en place Doxygen
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
# Compilation
|
# Compilation
|
||||||
build
|
build
|
||||||
|
doc
|
||||||
|
|
||||||
# Executables
|
# Executables
|
||||||
oki
|
oki
|
||||||
|
2658
cli/Doxyfile
Normal file
2658
cli/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
11
cli/Makefile
11
cli/Makefile
@@ -42,10 +42,17 @@ $(BUILD_DIR)/%.o: src/%.cpp | $(BUILD_DIR)
|
|||||||
$(BUILD_DIR):
|
$(BUILD_DIR):
|
||||||
mkdir -p $(subst src,$(BUILD_DIR),$(SRC_DIR))
|
mkdir -p $(subst src,$(BUILD_DIR),$(SRC_DIR))
|
||||||
|
|
||||||
|
# Génère la documentation avec Doxygen
|
||||||
|
doc/html/index.html: Doxyfile $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*.h))
|
||||||
|
doxygen
|
||||||
|
|
||||||
# Supprime tous les fichiers issus de la compilation
|
# Supprime tous les fichiers issus de la compilation
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR) $(TARGET_EXE)
|
rm -rf $(BUILD_DIR) $(TARGET_EXE) doc
|
||||||
|
|
||||||
|
doc: doc/html/index.html
|
||||||
|
|
||||||
|
.PHONY: all clean doc
|
||||||
|
|
||||||
# Inclut les Makefiles de chaque fichier source
|
# Inclut les Makefiles de chaque fichier source
|
||||||
# Le - permet d'ignorer les Makefiles manquants
|
# Le - permet d'ignorer les Makefiles manquants
|
||||||
|
@@ -4,16 +4,31 @@
|
|||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Liste tous les paquets disponibles.
|
||||||
|
*/
|
||||||
struct ListAction {
|
struct ListAction {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demande l'installation d'un paquet nommé.
|
||||||
|
*/
|
||||||
struct InstallAction {
|
struct InstallAction {
|
||||||
std::string_view packageName;
|
std::string_view packageName;
|
||||||
explicit InstallAction(const char *packageName) : packageName{packageName} {}
|
explicit InstallAction(const char *packageName) : packageName{packageName} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affiche les informations d'un paquet d'après son nom.
|
||||||
|
*/
|
||||||
struct ShowAction {
|
struct ShowAction {
|
||||||
std::string_view packageName;
|
std::string_view packageName;
|
||||||
explicit ShowAction(const char *packageName) : packageName{packageName} {}
|
explicit ShowAction(const char *packageName) : packageName{packageName} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toutes les actions possibles.
|
||||||
|
*/
|
||||||
using CliAction = std::variant<ListAction, InstallAction, ShowAction>;
|
using CliAction = std::variant<ListAction, InstallAction, ShowAction>;
|
||||||
|
|
||||||
CliAction parseArguments(int argc, char *argv[]);
|
CliAction parseArguments(int argc, char *argv[]);
|
||||||
|
@@ -3,6 +3,17 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Détermine le chemin par défaut vers le répertoire local de l'utilisateur.
|
||||||
|
*
|
||||||
|
* @return Le chemin à utiliser.
|
||||||
|
*/
|
||||||
std::filesystem::path getDefaultLocalRepository();
|
std::filesystem::path getDefaultLocalRepository();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Détermine si STDOUT supporte la couleur.
|
||||||
|
*
|
||||||
|
* @return Si STDOUT est un terminal.
|
||||||
|
*/
|
||||||
bool acceptColor();
|
bool acceptColor();
|
||||||
}
|
}
|
||||||
|
@@ -3,11 +3,25 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Un extracteur d'archives compressées au format ZIP.
|
||||||
|
*/
|
||||||
class Extractor {
|
class Extractor {
|
||||||
private:
|
private:
|
||||||
std::filesystem::path destination;
|
std::filesystem::path destination;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Créé un nouvel extracteur.
|
||||||
|
*
|
||||||
|
* @param destination Chemin vers le dossier où extraire les fichiers.
|
||||||
|
*/
|
||||||
explicit Extractor(std::filesystem::path destination);
|
explicit Extractor(std::filesystem::path destination);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extraire tous les fichiers à partir de l'archive dont le chemin est spécifié.
|
||||||
|
*
|
||||||
|
* @param archivePath Le chemin vers l'archive à décompresser.
|
||||||
|
*/
|
||||||
void extract(const std::filesystem::path &archivePath);
|
void extract(const std::filesystem::path &archivePath);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -4,17 +4,44 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Une requête HTTP, préparée par CURL.
|
||||||
|
*/
|
||||||
class HttpRequest {
|
class HttpRequest {
|
||||||
private:
|
private:
|
||||||
void *curl;
|
void *curl;
|
||||||
std::string url;
|
std::string url;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Instancie une nouvelle requête vers une url.
|
||||||
|
*
|
||||||
|
* @param url L'url à utiliser.
|
||||||
|
*/
|
||||||
explicit HttpRequest(std::string_view url);
|
explicit HttpRequest(std::string_view url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exécute la requête avec une méthode GET et capture le résultat dans une chaîne de caractères.
|
||||||
|
*
|
||||||
|
* @return Le contenu de la réponse du serveur.
|
||||||
|
*/
|
||||||
std::string get();
|
std::string get();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exécute la requête avec une méthode GET et télécharge la réponse dans un fichier.
|
||||||
|
*
|
||||||
|
* @param path Le chemin vers le fichier où télécharger.
|
||||||
|
*/
|
||||||
void download(const std::filesystem::path& path);
|
void download(const std::filesystem::path& path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vide la requête.
|
||||||
|
*/
|
||||||
~HttpRequest();
|
~HttpRequest();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Une erreur lors de la transmission de la requête.
|
||||||
|
*/
|
||||||
class RequestException : public std::exception {
|
class RequestException : public std::exception {
|
||||||
private:
|
private:
|
||||||
int code;
|
int code;
|
||||||
@@ -23,6 +50,9 @@ namespace oki{
|
|||||||
const char *what() const noexcept override;
|
const char *what() const noexcept override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Une erreur retournée par l'API.
|
||||||
|
*/
|
||||||
class APIException : public std::exception {
|
class APIException : public std::exception {
|
||||||
private:
|
private:
|
||||||
std::string msg;
|
std::string msg;
|
||||||
@@ -30,4 +60,4 @@ namespace oki{
|
|||||||
explicit APIException(std::string_view msg);
|
explicit APIException(std::string_view msg);
|
||||||
const char *what() const noexcept override;
|
const char *what() const noexcept override;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,28 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Un fichier temporaire utilisant le principe de RAII.
|
||||||
|
*/
|
||||||
class TmpFile {
|
class TmpFile {
|
||||||
private:
|
private:
|
||||||
char filename[20];
|
char filename[20];
|
||||||
int fd;
|
int fd;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Créé un nouveau fichier temporaire.
|
||||||
|
*/
|
||||||
TmpFile();
|
TmpFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère le chemin absolu vers le fichier temporaire.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
const char *getFilename();
|
const char *getFilename();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supprime le fichier temporaire.
|
||||||
|
*/
|
||||||
~TmpFile();
|
~TmpFile();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -5,13 +5,16 @@
|
|||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Un modèle de paquet pour échanger avec l'API.
|
||||||
|
*/
|
||||||
class Package {
|
class Package {
|
||||||
private:
|
private:
|
||||||
std::string shortName;
|
std::string shortName;
|
||||||
std::string longName;
|
std::string longName;
|
||||||
std::vector<Version> versions;
|
std::vector<Version> versions;
|
||||||
public:
|
public:
|
||||||
Package(std::string_view shortName, std::string_view longName, std::vector<Version> versions= {});
|
Package(std::string_view shortName, std::string_view longName, std::vector<Version> versions = {});
|
||||||
const std::string& getShortName() const;
|
const std::string& getShortName() const;
|
||||||
const std::string& getLongName() const;
|
const std::string& getLongName() const;
|
||||||
const std::vector<Version>& getVersions() const;
|
const std::vector<Version>& getVersions() const;
|
||||||
|
@@ -4,6 +4,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Un modèle de version d'un paquet pour communiquer avec l'API.
|
||||||
|
*/
|
||||||
class Version {
|
class Version {
|
||||||
private:
|
private:
|
||||||
std::string identifier;
|
std::string identifier;
|
||||||
@@ -15,4 +18,4 @@ namespace oki{
|
|||||||
const std::string& getPublishedDate() const;
|
const std::string& getPublishedDate() const;
|
||||||
const std::string& getDownloadUrl() const;
|
const std::string& getDownloadUrl() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,24 @@
|
|||||||
#include "../package/Package.h"
|
#include "../package/Package.h"
|
||||||
|
|
||||||
namespace oki{
|
namespace oki{
|
||||||
|
/**
|
||||||
|
* Un dépôt où sont référencés des paquets.
|
||||||
|
*/
|
||||||
class Repository {
|
class Repository {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Liste tous les paquets présents sur le dépôt.
|
||||||
|
*
|
||||||
|
* @return Tous les noms des paquets disponibles.
|
||||||
|
*/
|
||||||
virtual std::vector<Package> listPackages() = 0;
|
virtual std::vector<Package> listPackages() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère les informations détaillées d'un paquet nommé.
|
||||||
|
*
|
||||||
|
* @param packageName Le nom du paquet à utiliser.
|
||||||
|
* @return Les informations de ce paquet.
|
||||||
|
*/
|
||||||
virtual std::optional<Package> showPackage(std::string_view packageName) = 0;
|
virtual std::optional<Package> showPackage(std::string_view packageName) = 0;
|
||||||
virtual void download(const Version &packageVersion, const std::filesystem::path& destination) = 0;
|
virtual void download(const Version &packageVersion, const std::filesystem::path& destination) = 0;
|
||||||
virtual ~Repository() = default;
|
virtual ~Repository() = default;
|
||||||
|
Reference in New Issue
Block a user