-
Notifications
You must be signed in to change notification settings - Fork 0
/
force-mode.el
164 lines (134 loc) · 4.28 KB
/
force-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
;;; force-mode.el --- A functional force IDE -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defun force-cli-command (command)
"COMMAND."
(async-shell-command (concat "force " command)))
(defun force-cli-current-dir ()
"."
(let* ((current-file (current-file-path))
(current-dir (f-dirname current-file)))
(print current-dir)))
(defun force-cli--file-is-controller? (file)
"FILE."
(s-suffix? "controller.js" file))
(defun force-cli--file-is-helper? (file)
"FILE."
(s-suffix? "helper.js" file))
;; (defun force-cli-find-controller ()
;; "docstring"
;; (interactive)
;; (let* ((dir (force-cli-current-dir))
;; (files (f-files dir))
;; (isController (map #s-suffix? files))))
;; (print files))
(defun force-cli-login ()
"."
(interactive)
(async-shell-command "force login"))
(defun force-cli-fetch-classes ()
"Fetch classes."
(interactive)
(force-cli-command "fetch -t ApexClass"))
(defun force-cli-fetch-aura ()
"Fetches aura."
(interactive)
(force-cli-command "fetch -t aura"))
(defun force-cli-create-apex-class (class-name)
"CLASS-NAME Docstring."
(interactive "sClass Name: ")
(force-cli-command (concat "create -w apexclass -n " class-name)))
(defun force-cli-pull-package ()
"."
(interactive)
(progn
(print "exporting standard objects")
(force-cli-command "export")
(print "fetching aura")
(force-cli-fetch-aura)))
(defun force-cli-list-logins ()
"."
(interactive)
(async-shell-command "force logins"))
(defun force-cli-apex-class ()
"."
(interactive)
(progn
(print "Pushing Apex Class")
(let ((path (current-file-path)))
(force-cli-command (concat "force push -t ApexClass -f " path)))))
(defun force-cli-push-aura-file ()
"."
(interactive)
(progn
(print "Pushing Aura File")
(let ((path (current-file-path)))
(force-cli-command (concat "aura push -f " path)))))
(defun force-cli-push-apex-class ()
"."
(interactive)
(progn
(print "Pushing Apex Class")
(let ((path (current-file-path)))
(force-cli-command (concat "push -t ApexClass " path)))))
(defun force-cli-helm-complete (data)
"DATA."
(interactive)
(print (helm :sources (helm-build-sync-source "objects"
:candidates data
:fuzzy-match t)
:buffer "* Force cli completions *")))
(defun force-cli--parse-objectnames-from-response (response)
"RESPONSE."
(mapcar (lambda (x) (print (plist-get x :Name))) response))
;; (defun onSuccessCB (args)
;; )
;; (defun force-cli-complete (params)
;; (request
;; (concat "localhost:8080/complete")
;; :params params
;; :parser
;; (lambda ()
;; (let ((json-object-type 'plist))
;; (json-read)))
;; :success
;; (function* (lambda (&key data &allow-other-keys)
;; (progn
;; (setq results (append data '()))
;; (insert (force-cli-helm-complete results)))))))
;; This is messed up right now
;; completions
(defun force-cli-complete-ui ()
"."
(interactive)
(let ((results (force-cli-complete '(("type" . "ui")))))))
(defun force-cli-complete-vf ()
"."
(interactive)
(let ((results (force-cli-complete '(("type" . "vf")))))))
(defun force-cli-complete-classes ()
"."
(interactive)
(force-cli-complete '(("type" . "classes"))))
(defun force-cli-complete-class-methods (className)
"CLASSNAME."
(interactive "sClassName: ")
(force-cli-complete `(("type" . "classes")
("className" . ,className))))
(defvar force-cli-keymap nil "Keymap for Force-cli mode.")
(progn
(setq force-cli-keymap (make-sparse-keymap))
(define-key force-cli-keymap (kbd "C-c f p") 'force-cli-push-aura-file)
(define-key force-cli-keymap (kbd "C-c f c") 'force-cli-push-apex-class)
(define-key force-cli-keymap (kbd "C-c f l") 'force-cli-login))
(define-minor-mode force-mode
"A minor mode for interacting with the Force CLI, and other goodies."
:lighter " force-cli"
:keymap force-cli-keymap)
;; Add mode hooks
(add-to-list 'auto-mode-alist '("\\.app\\'" . html-mode))
(add-to-list 'auto-mode-alist '("\\.app\\'" . force-mode))
(add-to-list 'auto-mode-alist '("\\.cmp\\'" . html-mode))
(add-to-list 'auto-mode-alist '("\\.cmp\\'" . force-mode))
(provide 'force-mode)
;;; Force-Mode.el ends here