From 000740d5c7b6f3a73121420e2ddcf419213c19b8 Mon Sep 17 00:00:00 2001 From: tylen Date: Thu, 26 Sep 2024 19:28:16 +0000 Subject: [PATCH] cdo: use remote from args in platform identification issue #2 --- src/cdo.c | 35 +++++++++++++++++++---------------- src/platform/base.c | 2 +- src/platform/base.h | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/cdo.c b/src/cdo.c index f8b6669..9396e16 100644 --- a/src/cdo.c +++ b/src/cdo.c @@ -3,25 +3,28 @@ #include #include "cmd.h" -#include "tools/log.h" -#include "tools/alloc_wrappers.h" -#include "platform/operations.h" #include "platform/base.h" +#include "platform/operations.h" +#include "tools/alloc_wrappers.h" +#include "tools/log.h" static void __attribute__((constructor)) init_cdo(void) { - atexit(exit_cmd); - init_log(); - init_cmd(); + atexit(exit_cmd); + init_log(); + init_cmd(); } -int main (int argc, char *argv[]) { - LOG_DEBUG("Entering function %s", __func__); - struct ArgList* args = parse_args(argc, argv); - const char* relative_project_path = extract_value_from_arg(args, ARG_PROJECT); - const char* full_path = convert_relative_to_full_path(relative_project_path); - LOG_INFO("Project full path: %s", full_path); - identify_platfrom_from_project(full_path); - cdo_free((void*)full_path); - free_arg_list(args); - return 0; +int main(int argc, char* argv[]) { + LOG_DEBUG("Entering function %s", __func__); + struct ArgList* args = parse_args(argc, argv); + + const char* project_path = convert_relative_to_full_path(extract_value_from_arg(args, ARG_PROJECT)); + LOG_INFO("Project full path: %s", project_path); + PlaformId project_platform_id = identify_platfrom_from_project( + project_path, + extract_value_from_arg(args, ARG_REMOTE)); + + cdo_free((void*)project_path); + free_arg_list(args); + return 0; } diff --git a/src/platform/base.c b/src/platform/base.c index 3093356..125efbc 100644 --- a/src/platform/base.c +++ b/src/platform/base.c @@ -14,7 +14,7 @@ const char* SUPPORTED_PLATFORM_NAMES [] = { "gitlab.com" }; -PlaformId identify_platfrom_from_project(const char* project_path) { +PlaformId identify_platfrom_from_project(const char* project_path, const char* remote) { LOG_DEBUG("Entering function %s", __func__); if (project_path == NULL) { LOG_ERROR_EXIT("No path supplied for project."); diff --git a/src/platform/base.h b/src/platform/base.h index c759246..067bb4c 100644 --- a/src/platform/base.h +++ b/src/platform/base.h @@ -11,6 +11,6 @@ typedef enum PlaformId { extern const char* SUPPORTED_PLATFORM_NAMES []; -PlaformId identify_platfrom_from_project(const char* project_path); +PlaformId identify_platfrom_from_project(const char* project_path, const char* remote); #endif /*__PLATFORM_BASE_H__*/ \ No newline at end of file