feat(args): args_handler
This commit is contained in:
parent
d1f4e0e88d
commit
234713b6a0
2 changed files with 105 additions and 0 deletions
41
src/utils/args/args.h
Normal file
41
src/utils/args/args.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef ARGS_H
|
||||
#define ARGS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
enum input_type
|
||||
{
|
||||
INPUT_UNDEFINED,
|
||||
INPUT_FILE,
|
||||
INPUT_CMD,
|
||||
INPUT_STDIN
|
||||
};
|
||||
|
||||
struct args_options
|
||||
{
|
||||
/** Source of the input, filename or command string depending on type, NULL
|
||||
* if INPUT_STDIN */
|
||||
const char *input_source;
|
||||
/** Type of the input source */
|
||||
enum input_type type;
|
||||
/** Enable or disable pretty printing of outputs */
|
||||
bool pretty_print;
|
||||
/** Enable or disable verbose mode */
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles command-line arguments and populates the args_options structure.
|
||||
* @param argc The argument count.
|
||||
* @param argv The argument vector.
|
||||
* @param options Pointer to args_options structure to be populated.
|
||||
* @return 0 on success, non-zero on failure.
|
||||
*/
|
||||
int args_handler(int argc, char **argv, struct args_options *options);
|
||||
|
||||
/** Prints the parsed arguments for debugging purposes.
|
||||
* @param options Pointer to args_options structure containing parsed options.
|
||||
*/
|
||||
void args_print(struct args_options *options);
|
||||
|
||||
#endif /* ARGS_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue