crun-cli v1.4.0
C-based project scaffolding CLI
Loading...
Searching...
No Matches
crun.c File Reference

crun source file More...

#include "../inc/crun.h"
#include "../common/patterns.h"
#include "../inc/crun_audit.h"
#include "../inc/crun_file_manager.h"
#include "../inc/crun_json_manager.h"
#include "../inc/crun_libcurl.h"
#include "../inc/crun_zip_manager.h"
#include <cjson/cJSON.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
Include dependency graph for crun.c:

Functions

void crun_version ()
 Print app version.
void crun_help ()
 Print command-line usage/help.
int crun_update ()
 Refresh local stacks metadata from remote source.
void crun ()
 Main CLI flow entrypoint.
const char * download_crun_package (const struct CrunPackage *crun_package_map)
 Resolve package archive from cache or download it.
void get_user_choice (int *user_choice, const char *menu, const int limiter)
 Prompt for menu choice with validation.
void crun_stacks_json_checker (const char *crun_stacks_json_file_path)
 Ensure stacks metadata file exists locally.
char * get_language_buffer (cJSON *root)
 Build selectable language menu buffer from JSON root.
char * get_packages_buffer (cJSON *root, const char *language_name)
 Build selectable package menu buffer for one language.
void free_all (void **ptrs, size_t len)
 Release language/package maps and additional owned pointers.

Variables

struct CrunLanguagelanguages_map = NULL
size_t languages_map_length = 1
struct CrunPackagepackages_map = NULL
size_t packages_map_length = 1

Detailed Description

crun source file

Author
ZouariOmar (zouar.nosp@m.ioma.nosp@m.r20@g.nosp@m.mail.nosp@m..com)
Version
0.2
Date
2025-11-26

crun.c

Function Documentation

◆ crun()

void crun ( )

Main CLI flow entrypoint.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ crun_help()

void crun_help ( )

Print command-line usage/help.

Here is the caller graph for this function:

◆ crun_stacks_json_checker()

void crun_stacks_json_checker ( const char * crun_stacks_json_file_path)

Ensure stacks metadata file exists locally.

Parameters
crun_stacks_json_file_pathAbsolute path to local metadata file.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ crun_update()

int crun_update ( )

Refresh local stacks metadata from remote source.

Returns
int EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ crun_version()

void crun_version ( )

Print app version.

Here is the caller graph for this function:

◆ download_crun_package()

const char * download_crun_package ( const struct CrunPackage * crun_package_map)

Resolve package archive from cache or download it.

Parameters
crun_package_mapSelected package metadata.
Returns
const char* Allocated absolute path to package archive, or NULL on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_all()

void free_all ( void ** ptrs,
const size_t len )

Release language/package maps and additional owned pointers.

Parameters
ptrsExtra pointers to free.
lenNumber of pointers in ptrs.

◆ get_language_buffer()

char * get_language_buffer ( cJSON * root)

Build selectable language menu buffer from JSON root.

Parameters
rootParsed JSON root.
Returns
char* Allocated menu text buffer, or NULL on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_packages_buffer()

char * get_packages_buffer ( cJSON * root,
const char * language_name )

Build selectable package menu buffer for one language.

Parameters
rootParsed JSON root.
language_nameSelected language key.
Returns
char* Allocated menu text buffer, or NULL on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_user_choice()

void get_user_choice ( int * user_choice,
const char * menu,
const int limiter )

Prompt for menu choice with validation.

Parameters
user_choiceOutput selected value.
menuRendered menu text.
limiterUpper bound (exclusive), usually map length.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ languages_map

struct CrunLanguage* languages_map = NULL

◆ languages_map_length

size_t languages_map_length = 1

◆ packages_map

struct CrunPackage* packages_map = NULL

◆ packages_map_length

size_t packages_map_length = 1