app-example-01.lisp 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. (in-package :lilu-app-example)
  2. #|
  3. (defun make-and-register-browser (name version-script make-args-fn)
  4. (let ((app (make-instance 'program-application
  5. :name name
  6. :version-script version-script
  7. :make-args-fn make-args-fn
  8. :tags '(:browser))))
  9. (register-application app)))
  10. (make-and-register-browser "firefox2"
  11. "firefox --version | awk '{print $3}'"
  12. #'(lambda (application &optional url &rest args)
  13. (if url
  14. (list url)
  15. nil)))
  16. (defun test-01 (url)
  17. (let ((app01 (make-program-application :firefox
  18. "firefox2"
  19. "firefox --version | awk '{print $3}'"
  20. #'(lambda (application &optional url &rest args)
  21. (if url
  22. (list url)
  23. nil)))))
  24. #+nil(format *debug-io* "==>~A~%" (application-version app01))
  25. #+nil(run-application app01 (list url)
  26. :error-p t
  27. :wait-p t
  28. :callback-fn #'(lambda (app args ret)
  29. (format *debug-io* "==>~A ~A ~A~%" app args ret)))
  30. ))
  31. |#
  32. (defclass terminal-application (program-application)
  33. ((cmd-single-p :initarg :cmd-single-p))
  34. (:default-initargs
  35. :make-args-fn #'(lambda(app &optional cmd)
  36. (with-slots (cmd-single-p) app
  37. (if cmd
  38. (uiop:with-temporary-file (:stream strm :pathname file :keep t)
  39. (format strm (uiop:escape-sh-command cmd))
  40. (format strm "~%rm ~a" (uiop:unix-namestring file))
  41. :close-stream
  42. (if cmd-single-p
  43. (list "-e"
  44. (format nil "sh ~a" (uiop:unix-namestring file)))
  45. (list "-e" "sh"
  46. (format nil "~a" (uiop:unix-namestring file)))))
  47. nil)))))
  48. (defun make-terminal-application (string-designator
  49. program
  50. version-script
  51. cmd-single-p)
  52. (make-instance 'terminal-application
  53. :name (string string-designator)
  54. :program program
  55. :version-script version-script
  56. :cmd-single-p cmd-single-p
  57. :tags '(:terminal)))
  58. (defun register-terminal (string-designator
  59. program
  60. version-script
  61. cmd-single-p)
  62. (register-application
  63. (make-terminal-application string-designator program
  64. version-script cmd-single-p)))
  65. (register-terminal :xfce
  66. "xfce4-terminal"
  67. "xfce4-terminal --version | head -1 | awk '{print $2}'"
  68. t)
  69. (register-terminal :cool-retro
  70. "cool-retro-term"
  71. " cool-retro-term --version 2>&1 | awk '{ print $2 }'"
  72. nil)