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

Core crun CLI interfaces. More...

#include <cjson/cJSON.h>
#include <stdio.h>
#include <unistd.h>
Include dependency graph for crun.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CrunLanguage
struct  CrunPackage
struct  CrunRuntimeContext

Macros

#define __get_current_dir   getcwd
#define __get_pid   getpid

Functions

void crun ()
 Main CLI flow entrypoint.
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_stacks_json_checker (const char *)
 Ensure stacks metadata file exists locally.
void get_user_choice (int *, const char *, const int)
 Prompt for menu choice with validation.
const char * download_crun_package (const struct CrunPackage *)
 Resolve package archive from cache or download it.
char * get_language_buffer (cJSON *)
 Build selectable language menu buffer from JSON root.
char * get_packages_buffer (cJSON *, const char *)
 Build selectable package menu buffer for one language.
void free_all (void **, const size_t)
 Release language/package maps and additional owned pointers.

Detailed Description

Core crun CLI interfaces.

Author
ZouariOmar (zouar.nosp@m.ioma.nosp@m.r20@g.nosp@m.mail.nosp@m..com)
Version
0.3
Date
2026-03-18

crun.h

Macro Definition Documentation

◆ __get_current_dir

#define __get_current_dir   getcwd

◆ __get_pid

#define __get_pid   getpid

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: