-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseargs.h
More file actions
54 lines (43 loc) · 2.26 KB
/
parseargs.h
File metadata and controls
54 lines (43 loc) · 2.26 KB
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
#ifndef PARSEARGS_H
#define PARSEARGS_H
#include "map.h"
// TODO maybe instead of naming by what char indicates what the state is
// label by what it actually indicates
typedef enum State_t {
Error, // 0 means error
Space, // 1 was a space so were on a new set of values
Comma, // 2 was a comma so were on the same set of values
Equals, // 3 was an equals so were looking at a default val
Semicolon, // 4 was a semicolon so were done
} State;
// i need to define what errors are
typedef enum Errors_t {
Success = 0,
NotAlnum = 1,
DidNotFind,
} Errors;
// TODO are there any other shells i should try to support?
// - elvish? (no idea what this is, just saw it in a completion help thing on some program)
// - powershell (id have to look into it, but this probably doesnt make sense becuase you probably want to just hook into the powershell get-help framework (if thats how that works)
// - awk (no idea if this is practical or possible or helpful but could be cool to just have an awk script with good command line options)
typedef enum {
SH,
BASH,
ZSH,
KSH,
CSH,
FISH,
XONSH,
} Shell;
typedef struct {
bool print;
bool unknownPositional;
} ParseArgsOptions;
char * parseArgSpec(char * buf, map_t * map, char argType[], void * defaultValue, DataType defaultType, bool allowDefaults, MapData * * * const positionalArray);
State setState(char * c);
Errors parseArgs(const int argc, const char * const * argv, map_t * flagMap, map_t * paramMap, MapData * positionalNodes[], const char * * positionalParams_ptr[], bool unknownPositional);
//Errors parseArgsBase(const int argc, const char * const * argv, map_t * flagMap, map_t * paramMap, MapData * positionalNodes[], const char * * positionalParams_ptr[], const ParseArgsOptions * opts);
Errors parseArgsBase(const int argc, const char * const * argv, map_t * flagMap, map_t * paramMap, MapData * positionalNodes[], const char * * positionalParams_ptr[], bool unknownPositional, bool print);
int printUsage(const map_t * flagMap, const map_t * paramMap, const MapData * * positionalParams, const char * progname);
int printHelp(const map_t * flagMap, const map_t * paramMap, const MapData * positionalParams[], const char * helpMessages);
#endif // PARSEARGS_H