Skip to content

Commit bc7482d

Browse files
committed
[Refacto] removing group description
1 parent a6e9e16 commit bc7482d

File tree

9 files changed

+23
-30
lines changed

9 files changed

+23
-30
lines changed

benchmarks/benchmark_release_mode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ ARGUS_OPTIONS(
1212
HELP_OPTION(),
1313
VERSION_OPTION(),
1414

15-
GROUP_START("Input Options", GROUP_DESC("Options related to input")),
15+
GROUP_START("Input Options"),
1616
OPTION_FLAG('v', "verbose", HELP("Enable verbose output")),
1717
OPTION_STRING('i', "input", HELP("Input file"), DEFAULT("input.txt")),
1818
OPTION_ARRAY_STRING('I', "include", HELP("Include files"), FLAGS(FLAG_SORTED | FLAG_UNIQUE)),
1919
GROUP_END(),
2020

21-
GROUP_START("Output Options", GROUP_DESC("Options related to output")),
21+
GROUP_START("Output Options"),
2222
OPTION_STRING('o', "output", HELP("Output file"), DEFAULT("output.txt")),
2323
OPTION_STRING('f', "format", HELP("Output format"),
2424
VALIDATOR(V_CHOICE_STR("text", "json", "xml", "binary"))),
2525
OPTION_FLAG('s', "silent", HELP("Suppress output"), CONFLICT("verbose")),
2626
GROUP_END(),
2727

28-
GROUP_START("Processing Options", GROUP_DESC("Options controlling processing")),
28+
GROUP_START("Processing Options"),
2929
OPTION_INT('l', "level", HELP("Processing level"),
3030
VALIDATOR(V_RANGE(1, 10)), DEFAULT(5)),
3131
OPTION_INT('j', "jobs", HELP("Number of parallel jobs"),
@@ -35,7 +35,7 @@ ARGUS_OPTIONS(
3535
OPTION_MAP_STRING('D', "define", HELP("Define variables"), FLAGS(FLAG_SORTED_KEY)),
3636
GROUP_END(),
3737

38-
GROUP_START("Advanced Options", GROUP_DESC("Advanced configuration")),
38+
GROUP_START("Advanced Options"),
3939
OPTION_FLAG('d', "debug", HELP("Enable debug mode")),
4040
OPTION_STRING('c', "config", HELP("Configuration file")),
4141
OPTION_ARRAY_INT('p', "ports", HELP("Port numbers"), FLAGS(FLAG_SORTED | FLAG_UNIQUE)),

docs/docs/appendices/cheat-sheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ endpoint_t *ep = (endpoint_t*)argus_get(&argus, "endpoint").as_ptr;
260260
## // Groups
261261
262262
```c
263-
GROUP_START("Connection", GROUP_DESC("Network options")),
263+
GROUP_START("Connection"),
264264
OPTION_STRING('h', "host", HELP("Hostname")),
265265
OPTION_INT('p', "port", HELP("Port")),
266266
GROUP_END(),
267267
268-
GROUP_START("Output", GROUP_DESC("Output options")),
268+
GROUP_START("Output"),
269269
OPTION_STRING('o', "output", HELP("Output file")),
270270
OPTION_STRING('f', "format", HELP("Format")),
271271
GROUP_END(),

docs/docs/fundamentals/help-and-errors.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ ARGUS_OPTIONS(
207207
options,
208208
HELP_OPTION(),
209209

210-
GROUP_START("Connection", GROUP_DESC("Network connection options")),
210+
GROUP_START("Connection"),
211211
OPTION_STRING('H', "host", HELP("Server hostname"), DEFAULT("localhost")),
212212
OPTION_INT('p', "port", HELP("Server port"), DEFAULT(8080)),
213213
OPTION_FLAG('s', "secure", HELP("Use HTTPS")),
214214
GROUP_END(),
215215

216-
GROUP_START("Output", GROUP_DESC("Output formatting options")),
216+
GROUP_START("Output"),
217217
OPTION_STRING('f', "format", HELP("Output format"), DEFAULT("json")),
218218
OPTION_FLAG('v', "verbose", HELP("Verbose output")),
219219
GROUP_END(),
@@ -538,14 +538,14 @@ ARGUS_OPTIONS(
538538
HELP_OPTION(),
539539

540540
// Input/Output options
541-
GROUP_START("Input/Output", GROUP_DESC("File and data handling options")),
541+
GROUP_START("Input/Output"),
542542
OPTION_STRING('i', "input", HELP("Input file or directory")),
543543
OPTION_STRING('o', "output", HELP("Output destination")),
544544
OPTION_STRING('f', "format", HELP("Output format")),
545545
GROUP_END(),
546546

547547
// Processing options
548-
GROUP_START("Processing", GROUP_DESC("Algorithm and performance options")),
548+
GROUP_START("Processing"),
549549
OPTION_INT('t', "threads", HELP("Worker threads")),
550550
OPTION_FLOAT('q', "quality", HELP("Processing quality")),
551551
OPTION_FLAG('F', "fast", HELP("Use fast mode (lower quality)")),

examples/advanced_options.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ ARGUS_OPTIONS(
1818
OPTION_STRING('i', "input", HELP("Input file"), FLAGS(FLAG_REQUIRED)),
1919

2020
// Compression options in an exclusive group (only one can be selected)
21-
GROUP_START("Compression", GROUP_DESC("Compression options"),
22-
FLAGS(FLAG_EXCLUSIVE)),
21+
GROUP_START("Compression", FLAGS(FLAG_EXCLUSIVE)),
2322
OPTION_FLAG('z', "gzip", HELP("Use gzip compression")),
2423
OPTION_FLAG('j', "bzip2", HELP("Use bzip2 compression")),
2524
OPTION_FLAG('Z', "lzma", HELP("Use lzma compression")),

includes/argus/internal/help.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ typedef struct option_entry_s
3131
typedef struct group_info_s
3232
{
3333
const char *name;
34-
const char *description;
3534
option_entry_t *options;
3635
struct group_info_s *next;
3736
} group_info_t;
@@ -68,10 +67,9 @@ void add_option_to_list(option_entry_t **list, const argus_option_t *option);
6867
*
6968
* @param data Help data structure
7069
* @param name Group name
71-
* @param description Group description
7270
* @return Group info structure or NULL on failure
7371
*/
74-
group_info_t *find_or_create_group(help_data_t *data, const char *name, const char *description);
72+
group_info_t *find_or_create_group(help_data_t *data, const char *name);
7573

7674
/**
7775
* Organize options into categories for display

includes/argus/options.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ ARGUS_API char *format_choices_validator(validator_data_t data);
6767
* Optional option fields macros
6868
*/
6969
#ifdef ARGUS_DEBUG
70-
# define ARGUS_DEBUG_INFO() .line = __LINE__, .file = __FILE__
70+
# define ARGUS_DEBUG_INFO .line = __LINE__, .file = __FILE__
7171
#else
72-
# define ARGUS_DEBUG_INFO() .line = 0, .file = NULL
72+
# define ARGUS_DEBUG_INFO .line = 0, .file = NULL
7373
#endif /* ARGUS_DEBUG */
7474
#define DEFINE_NAME(lname, sname) ((lname) ? (lname) : CHAR_TO_STRING(sname))
7575
#define DEFAULT(val) .value = (argus_value_t){ .raw = (uintptr_t)(val) }, \
@@ -82,7 +82,6 @@ ARGUS_API char *format_choices_validator(validator_data_t data);
8282
#define HINT(_hint) .hint = _hint
8383
#define REQUIRE(...) .require = (const char*[]){__VA_ARGS__, NULL}
8484
#define CONFLICT(...) .conflict = (const char*[]){__VA_ARGS__, NULL}
85-
#define GROUP_DESC(desc) .help = desc
8685
#define HELP(desc) .help = desc
8786
#define FLAGS(_flags) .flags = _flags
8887
#define ENV_VAR(name) .env_name = name
@@ -143,30 +142,30 @@ ARGUS_API char *format_choices_validator(validator_data_t data);
143142
.type = TYPE_NONE, \
144143
.name = NULL, \
145144
.value_type = VALUE_TYPE_NONE, \
146-
ARGUS_DEBUG_INFO() \
145+
ARGUS_DEBUG_INFO \
147146
}
148147

149148
#define OPTION_BASE(_short, _long, _value_type, ...) \
150149
(argus_option_t) { \
151150
.type = TYPE_OPTION, .name = DEFINE_NAME(_long, _short), \
152151
.sname = _short, .lname = _long, .value_type = _value_type, \
153-
.free_handler = default_free, ARGUS_DEBUG_INFO(), ##__VA_ARGS__ \
152+
.free_handler = default_free, ARGUS_DEBUG_INFO, ##__VA_ARGS__ \
154153
}
155154

156155
#define POSITIONAL_BASE(_name, _value_type, ...) \
157156
(argus_option_t) { \
158157
.type = TYPE_POSITIONAL, .name = _name, .value_type = _value_type, \
159-
.free_handler = default_free, .flags = FLAG_REQUIRED, ARGUS_DEBUG_INFO(), ##__VA_ARGS__ \
158+
.free_handler = default_free, .flags = FLAG_REQUIRED, ARGUS_DEBUG_INFO, ##__VA_ARGS__ \
160159
}
161160

162161
#define GROUP_BASE(_name, ...) \
163162
(argus_option_t) { \
164-
.type = TYPE_GROUP, .name = _name, ARGUS_DEBUG_INFO(), ##__VA_ARGS__ \
163+
.type = TYPE_GROUP, .name = _name, ARGUS_DEBUG_INFO, ##__VA_ARGS__ \
165164
}
166165

167166
#define SUBCOMMAND_BASE(_name, sub_opts, ...) \
168167
(argus_option_t) { \
169-
.type = TYPE_SUBCOMMAND, .name = _name, .sub_options = sub_opts, ARGUS_DEBUG_INFO(), ##__VA_ARGS__ \
168+
.type = TYPE_SUBCOMMAND, .name = _name, .sub_options = sub_opts, ARGUS_DEBUG_INFO, ##__VA_ARGS__ \
170169
}
171170

172171
// clang-format on

source/display/help/help_organizer.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void add_option_to_list(option_entry_t **list, const argus_option_t *option)
4343
}
4444
}
4545

46-
group_info_t *find_or_create_group(help_data_t *data, const char *name, const char *description)
46+
group_info_t *find_or_create_group(help_data_t *data, const char *name)
4747
{
4848
group_info_t *group = data->groups;
4949
while (group != NULL) {
@@ -57,7 +57,6 @@ group_info_t *find_or_create_group(help_data_t *data, const char *name, const ch
5757
return NULL;
5858

5959
group->name = name;
60-
group->description = description;
6160
group->options = NULL;
6261
group->next = NULL;
6362

@@ -76,7 +75,6 @@ group_info_t *find_or_create_group(help_data_t *data, const char *name, const ch
7675
void organize_options(const argus_option_t *options, help_data_t *data)
7776
{
7877
const char *current_group = NULL;
79-
const char *current_group_desc = NULL;
8078
group_info_t *group = NULL;
8179

8280
for (int i = 0; options[i].type != TYPE_NONE; ++i) {
@@ -85,7 +83,6 @@ void organize_options(const argus_option_t *options, help_data_t *data)
8583
switch (option->type) {
8684
case TYPE_GROUP:
8785
current_group = option->name;
88-
current_group_desc = option->help;
8986
group = NULL;
9087
break;
9188

@@ -95,7 +92,7 @@ void organize_options(const argus_option_t *options, help_data_t *data)
9592

9693
if (current_group != NULL) {
9794
if (group == NULL)
98-
group = find_or_create_group(data, current_group, current_group_desc);
95+
group = find_or_create_group(data, current_group);
9996
add_option_to_list(&group->options, option);
10097
} else
10198
add_option_to_list(&data->ungrouped, option);

source/display/help/help_renderer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void print_help_sections(argus_t *argus, help_data_t *data)
116116
group_info_t *group = data->groups;
117117
while (group != NULL) {
118118
if (group->options != NULL) {
119-
printf("\n%s:\n", group->description ? group->description : group->name);
119+
printf("\n%s:\n", group->name);
120120
print_option_list(argus, group->options, argus->helper.config.option_indent);
121121
}
122122
group = group->next;

tests/integration/test_post_validation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ARGUS_OPTIONS(
2020
ARGUS_OPTIONS(
2121
group_options,
2222
HELP_OPTION(),
23-
GROUP_START("Compression", GROUP_DESC("Compression options"), FLAGS(FLAG_EXCLUSIVE)),
23+
GROUP_START("Compression", FLAGS(FLAG_EXCLUSIVE)),
2424
OPTION_FLAG('z', "gzip", HELP("Use gzip compression")),
2525
OPTION_FLAG('j', "bzip2", HELP("Use bzip2 compression")),
2626
GROUP_END(),

0 commit comments

Comments
 (0)