clish.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //-------------------------------------
  2. // clish.cpp
  3. //
  4. // A simple client for libclish
  5. //-------------------------------------
  6. #include "clish/private.h"
  7. static
  8. clish_shell_hooks_t my_hooks =
  9. {
  10. NULL, /* don't worry about init callback */
  11. clish_access_callback,
  12. NULL, /* don't worry about cmd_line callback */
  13. clish_script_callback,
  14. NULL, /* don't worry about fini callback */
  15. clish_config_callback,
  16. NULL /* don't register any builtin functions */
  17. };
  18. //---------------------------------------------------------
  19. int
  20. main(int argc, const char **argv)
  21. {
  22. int result = -1;
  23. clish_startup(argc,argv);
  24. if(argc > 1)
  25. {
  26. int i = 1;
  27. while(argc--)
  28. {
  29. /* run the commands in the file */
  30. result = clish_shell_spawn_from_file(&my_hooks,NULL,argv[i++]);
  31. }
  32. }
  33. else
  34. {
  35. /* spawn the shell */
  36. result = clish_shell_spawn_and_wait(&my_hooks,NULL);
  37. }
  38. clish_shutdown();
  39. return result ? 0 : -1;
  40. }
  41. //---------------------------------------------------------