-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwb.c
74 lines (59 loc) · 1.75 KB
/
pwb.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "pwb_builtin.h"
#include "pwb_actions.h"
#include <argeater.h>
#include <pager.h>
#include "pwb_handle.h"
#include "pwb_errors.h"
#include <stdio.h>
const char *help_flag = NULL;
const char *data_source = NULL;
const char *printer_function = NULL;
const char *exec_function = NULL;
const char *data_extra = NULL;
AE_ITEM actions[] = {
{ &help_flag, "help", 'h', AET_FLAG_OPTION,
"Show usage instructions", NULL,
argeater_string_setter },
{ &data_source, "data_source", 'd', AET_VALUE_OPTION,
"Name of a Bash data source", "DATA",
argeater_string_setter },
{ &printer_function, "printer_function", 'p', AET_VALUE_OPTION,
"Name of a printer function", "PRINTER",
argeater_string_setter },
{ &exec_function, "exec_function", 'e', AET_VALUE_OPTION,
"(Optional) execution function", "EXEC_FUNCTION",
argeater_string_setter },
{ &data_extra, "data_extra", 'x', AET_VALUE_OPTION,
"(Optional) name of Bash variable to pass to print and exec functions",
"EXTRA_DATA",
argeater_string_setter }
};
void show_usage(AE_MAP *map)
{
argeater_show_usage(map,"pwb");
argeater_show_options(map, 3);
argeater_show_arguments(map, 3);
}
static int pwb_builtin(WORD_LIST *list)
{
int exit_code = EXECUTION_FAILURE;
pwb_error_clear();
argeater_set_error_sink(pwb_error_shell_var);
PWB_RESULT result = perform_verb(list);
if (result == PWB_SUCCESS)
exit_code = EXECUTION_SUCCESS;
return exit_code;
}
static char *desc_pwb[] = {
"pwb - Pager with benefits",
"",
(char*)NULL
};
struct builtin pwb_struct = {
.name = "pwb",
.function = pwb_builtin,
.flags = BUILTIN_ENABLED,
.long_doc = desc_pwb,
.short_doc = "pwb file_name [OPTIONS]",
.handle = 0
};