summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-06-06 22:55:13 +0100
committerFreeArtMan <dos21h@gmail.com>2017-06-06 22:55:13 +0100
commit647bb24c29006fabaa3aee649da728f0fa94864c (patch)
tree5432dcd0b6fa0247cbd8ea9efc9cc17f9a7c6a04 /test
parent622c73263fb0a27cf0fe77247d5a0e0db4b9fdd3 (diff)
downloadlibarg-647bb24c29006fabaa3aee649da728f0fa94864c.tar.gz
libarg-647bb24c29006fabaa3aee649da728f0fa94864c.zip
Added result output way from config
Diffstat (limited to 'test')
-rw-r--r--test/test1.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/test/test1.c b/test/test1.c
index 1b1e98e..5d9cb0c 100644
--- a/test/test1.c
+++ b/test/test1.c
@@ -7,7 +7,8 @@
s_arg_ip src_ip =
{
.port = 8080,
- .ip = 0x7f000001
+ .ip = 0x7f000001,
+ .result = NULL
};
//?
@@ -16,12 +17,14 @@ s_arg_range freq_range =
{
.start = 88,
.end = 108,
- .step = 100e3
+ .step = 100e3,
+ .result = NULL
};
s_arg_float ratio_float =
{
- .val = 0.8
+ .val = 0.8,
+ .result = NULL
};
char *color_list[] = {"RED","GREEN","BLUE"};
@@ -30,24 +33,33 @@ s_arg_list color_name_list =
{
.num = 3,
.default_val = "RED",
- .vals = color_list
+ .vals = color_list,
+ .result = NULL
};
s_arg_val number_val =
{
- .ptr = NULL
+ .ptr = NULL,
+ .default_ptr = NULL,
+ .result = NULL
+};
+
+s_arg_flag flag_help =
+{
+ .used = 0,
+ .result = NULL
};
//cant be const
def_arg cmd_arg[] =
{
- ARG_ENTRY("-a",IP,&src_ip),
- ARG_ENTRY("-b",RANGE,&freq_range),
- ARG_ENTRY("-c",FLOAT,&ratio_float),
- ARG_ENTRY("-d",LIST,&color_name_list),
- ARG_ENTRY("-e",VAL,&number_val),
- ARG_ENTRY("-f",FILE,NULL),
- ARG_ENTRY("-g",FLAG,NULL),
+ ARG_ENTRY("-a",IP, &src_ip,"test ip address argument"),
+ ARG_ENTRY("-b",RANGE,&freq_range,"test integer range argument"),
+ ARG_ENTRY("-c",FLOAT,&ratio_float,"test float number"),
+ ARG_ENTRY("-d",LIST, &color_name_list,"check list of values"),
+ ARG_ENTRY("-e",VAL, &number_val,"check number values"),
+ ARG_ENTRY("-f",FILE, NULL,"check file argument"),
+ ARG_ENTRY("-g",FLAG, &flag_help,"check flag argument"),
{NULL,0,NULL}
};
@@ -61,7 +73,7 @@ int main( int argc, char **argv )
i = 0;
while ( cmd_arg[i].param != NULL )
{
- printf("%s\n",cmd_arg[i].param);
+ printf("%s - %s\n",cmd_arg[i].param, cmd_arg[i].help);
i++;
}
@@ -70,7 +82,7 @@ int main( int argc, char **argv )
if (cfg->size == 0)
{
printf("No arguments found\n");
- goto exit_error;
+ //goto exit_error;
}
for (i=0;i<cfg->size;i++)
@@ -78,7 +90,12 @@ int main( int argc, char **argv )
printf("TYPE:%d\n", cfg->arg[i]->type);
}
- arg_print( cfg );
+ //arg_print( cfg );
+
+ if (flag_help.result != NULL)
+ {
+ printf("Help flag\n");
+ }
arg_free( cfg );