ytree.c 920 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <faux/faux.h>
  4. #include <faux/argv.h>
  5. #include <sysrepo.h>
  6. #include <sysrepo/xpath.h>
  7. #include "klish_plugin_sysrepo.h"
  8. int main(int argc, char **argv)
  9. {
  10. int ret = -1;
  11. int err = SR_ERR_OK;
  12. sr_conn_ctx_t *conn = NULL;
  13. sr_session_ctx_t *sess = NULL;
  14. faux_argv_t *args = faux_argv_new();
  15. pline_t *pline = NULL;
  16. pline_opts_t opts;
  17. if (argc < 2)
  18. return -1;
  19. err = sr_connect(SR_CONN_DEFAULT, &conn);
  20. if (err) {
  21. printf("Error\n");
  22. goto out;
  23. }
  24. err = sr_session_start(conn, SR_DS_RUNNING, &sess);
  25. if (err) {
  26. printf("Error2\n");
  27. goto out;
  28. }
  29. pline_opts_init(&opts);
  30. faux_argv_parse(args, argv[1]);
  31. faux_argv_del_continuable(args);
  32. pline = pline_parse(sess, args, &opts);
  33. faux_argv_free(args);
  34. pline_debug(pline);
  35. pline_print_completions(pline, BOOL_TRUE, PT_COMPL_ALL);
  36. pline_free(pline);
  37. ret = 0;
  38. out:
  39. sr_disconnect(conn);
  40. return ret;
  41. }