cmdline: big rework and clean of cmdline library
[libcmdline.git] / TODO.txt
index 2e8fe54..dbdb2a1 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,7 +1,95 @@
-- token file/path
+- token file/path: pour ca il faut changer la logique get_nb/complete
+  pour se rapprocher du opendir/readdir
 - libevent example
 - better example than calculator
 - check all XXX in code
 - set prompt example
 - too much possible completion
 - token string entre guillemets ?
+- cmdline_parse() n'a pas besoin de retourner tokenlen
+- les help() des tokens (string par ex) ne retournent pas "faux" en cas d'erreur
+- on pourrait virer la valeur de retour du start() en reorganisant
+  cmdline_parse() et cmdline_help()
+- genconf: completion des xpath //
+- supprimer tous les basic_char_loop()
+
+---------------
+
+buf->linebuf
+
+- rdline: API peut rester comme ca
+ doit pouvoir etre utiisé seule
+ il fuat un example
+
+- parse:
+ doit aussi pouvoir etre utilisé seule
+ il faut virer les references a cmdline/rdline
+
+/* opaque is given to the token callback func */
+int cmdline_parse(parse_ctx, const char *buf, void *opaque);
+
+
+cmdline_complete_init(cmplt_ctx)
+
+/**
+ * complete() must be called with an initialized context
+ * with *state==-1 (just display choices), then called until it
+ * returns CMDLINE_PARSE_COMPLETED_BUFFER or
+ * CMDLINE_PARSE_COMPLETE_FINISHED.
+ *
+ * It returns < 0 on error.
+ *
+ * Else it returns:
+ *   - CMDLINE_PARSE_COMPLETED_BUFFER on completion (one possible
+ *     choice). In this case, the chars are appended in dst buffer.
+ *   - CMDLINE_PARSE_COMPLETE_AGAIN if there is several possible
+ *     choices. In this case, you must call the function again with
+ *     the same context
+ *   - CMDLINE_PARSE_COMPLETE_FINISHED when the iteration is
+ *     finished. The dst is not valid for this last call.
+ *
+ * The returned dst buf ends with \0.
+ */
+int cmdline_complete(parse_ctx, const char *buf, cmplt_ctx,
+                    char *dst, unsigned int size);
+
+
+- cmdline est un assemblage de rdline et parse
+  permet de parser des fichiers, de faire un prompt sur stdin, network, unix
+
+tests unitaires
+
+
+--------------
+
+completions possibles
+
+toto
+toti
+titi
+coin
+
+"" -> all (help)
+complete = "toto", complete_len = 4
+complete = "tot", complete_len = 3
+complete = "t", complete_len = 1
+complete = "", complete_len = 0
+n_completions = 4
+
+
+"t" -> "toto" "toti" "titi" (help)
+toklen = 1
+complete = "toto", complete_len = 4
+complete = "tot", complete_len = 3
+complete = "t", complete_len = 1
+n_completions = 3
+
+"to" -> "tot" (complete, not finished)
+toklen = 2
+complete = "toto", complete_len = 4
+complete = "tot", complete_len = 3
+n_completions = 2
+
+"ti" -> "titi " (complete, finished)
+n_completions = 1
+