cmdline: add the incomplete token string as an argument of iter_start()
[libcmdline.git] / TODO.txt
1 - token file/path: pour ca il faut changer la logique get_nb/complete
2   pour se rapprocher du opendir/readdir
3 - libevent example
4 - better example than calculator
5 - check all XXX in code
6 - set prompt example
7 - too much possible completion
8 - token string entre guillemets ?
9 - cmdline_parse() n'a pas besoin de retourner tokenlen
10 - les help() des tokens (string par ex) ne retournent pas "faux" en cas d'erreur
11 - on pourrait virer la valeur de retour du start() en reorganisant
12   cmdline_parse() et cmdline_help()
13 - genconf: completion des xpath //
14 - supprimer tous les basic_char_loop()
15
16 ---------------
17
18 buf->linebuf
19
20 - rdline: API peut rester comme ca
21  doit pouvoir etre utiisé seule
22  il fuat un example
23
24 - parse:
25  doit aussi pouvoir etre utilisé seule
26  il faut virer les references a cmdline/rdline
27
28 /* opaque is given to the token callback func */
29 int cmdline_parse(parse_ctx, const char *buf, void *opaque);
30
31
32 cmdline_complete_init(cmplt_ctx)
33
34 /**
35  * complete() must be called with an initialized context
36  * with *state==-1 (just display choices), then called until it
37  * returns CMDLINE_PARSE_COMPLETED_BUFFER or
38  * CMDLINE_PARSE_COMPLETE_FINISHED.
39  *
40  * It returns < 0 on error.
41  *
42  * Else it returns:
43  *   - CMDLINE_PARSE_COMPLETED_BUFFER on completion (one possible
44  *     choice). In this case, the chars are appended in dst buffer.
45  *   - CMDLINE_PARSE_COMPLETE_AGAIN if there is several possible
46  *     choices. In this case, you must call the function again with
47  *     the same context
48  *   - CMDLINE_PARSE_COMPLETE_FINISHED when the iteration is
49  *     finished. The dst is not valid for this last call.
50  *
51  * The returned dst buf ends with \0.
52  */
53 int cmdline_complete(parse_ctx, const char *buf, cmplt_ctx,
54                      char *dst, unsigned int size);
55
56
57 - cmdline est un assemblage de rdline et parse
58   permet de parser des fichiers, de faire un prompt sur stdin, network, unix
59
60 tests unitaires
61
62
63 --------------
64
65 completions possibles
66
67 toto
68 toti
69 titi
70 coin
71
72 "" -> all (help)
73 complete = "toto", complete_len = 4
74 complete = "tot", complete_len = 3
75 complete = "t", complete_len = 1
76 complete = "", complete_len = 0
77 n_completions = 4
78
79
80 "t" -> "toto" "toti" "titi" (help)
81 toklen = 1
82 complete = "toto", complete_len = 4
83 complete = "tot", complete_len = 3
84 complete = "t", complete_len = 1
85 n_completions = 3
86
87 "to" -> "tot" (complete, not finished)
88 toklen = 2
89 complete = "toto", complete_len = 4
90 complete = "tot", complete_len = 3
91 n_completions = 2
92
93 "ti" -> "titi " (complete, finished)
94 n_completions = 1
95