all repos — conver-tool @ 8e89942a0b72db7185ce063a57a90c281cf09575

A command line tool to manage ConVer projects.

Implementing draft (renamed from release).
h3rald h3rald@h3rald.com
Wed, 10 Jun 2026 07:31:28 +0200
commit

8e89942a0b72db7185ce063a57a90c281cf09575

parent

4a69a0711f0c5244f6cc276d7f7ba3eb438db3ff

2 files changed, 32 insertions(+), 19 deletions(-)

jump to
M src/conver.csrc/conver.c

@@ -189,38 +189,51 @@ print_result(fs_file_create(CONVER_HISTORY_FILE));

} } -void command_release() +void command_draft() { - char input_score[64]; - uint16_t score; + char score[16]; int valid = 0; + while (!valid) { printf("Specify the dependability score of the release [001-FFF]: "); - fgets(input_score, sizeof(input_score), stdin); - if (strlen(input_score) > 4) { - print_result(CONVER_ERR_INVALID_SCORE); + fgets(score, sizeof(score), stdin); + if (strlen(score) > 4) { + print_result(CONVER_ERR_INVALID_VALUE); continue; } int invalid_digit = 0; - for (int i=0; i<3; i++){ - if (!isxdigit(input_score[i])){ + for (int i=0; i<strlen(score)-1; i++){ + if (!isxdigit(score[i])){ invalid_digit = 1; - printf("Invalid: %c", input_score[i]); + printf("Invalid: %c", score[i]); break; } } if (invalid_digit) { - print_result(CONVER_ERR_INVALID_SCORE); + print_result(CONVER_ERR_INVALID_VALUE); + continue; + } + valid = 1; + } + printf("Score: %s\n", score); + valid = 0; + char size[16]; + while (!valid) { + printf("Specify the size of the release [S, M, L, X]: "); + fgets(size, sizeof(size), stdin); + if (strlen(size)> 2) { + print_result(CONVER_ERR_INVALID_VALUE); continue; } - score = (uint16_t)strtoul(input_score, NULL, 16); - if (score <= 0) { - print_result(CONVER_ERR_INVALID_SCORE); + if (size[0] != 'S' && size[0] != 's' && size[0] != 'M' && size[0] != 'm' && + size[0] != 'L' && size[0] != 'l' && size[0] != 'X' && size[0] != 'x') + { + print_result(CONVER_ERR_INVALID_VALUE); continue; - } + } valid = 1; } - printf("Score: %4X\n", score); + printf("Size: %s\n", size); } //// Main

@@ -242,9 +255,9 @@ if ((strcmp(arg, "init") == 0))

{ command_init(); } - if ((strcmp(arg, "release") == 0)) + if ((strcmp(arg, "draft") == 0)) { - command_release(); + command_draft(); } } }
M src/conver.hsrc/conver.h

@@ -26,7 +26,7 @@ CONVER_ERR_READ = 3,

CONVER_ERR_ALLOC = 4, CONVER_ERR_STAT = 5, CONVER_ERR_MKDIR = 6, - CONVER_ERR_INVALID_SCORE = 7 + CONVER_ERR_INVALID_VALUE = 7, } conver_result_t; char * conver_errors[8] = {

@@ -37,7 +37,7 @@ "Unable to read file",

"Unable to allocate memory for file", "Unable to get file/directory information", "Unable to create directory", - "Invalid dependability score" + "Invalid value", }; #endif // CONVER_H