Skip to content

Commit 8e3a913

Browse files
committed
Handle proxy
1 parent ed28233 commit 8e3a913

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

eask

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ yargs
2929
alias: 'dev',
3030
type: 'boolean',
3131
})
32+
.option('proxy', {
33+
description: 'update proxy for HTTP and HTTPS to host',
34+
type: 'string',
35+
})
36+
.option('http-proxy', {
37+
description: 'update proxy for HTTP to host',
38+
type: 'string',
39+
})
40+
.option('https-proxy', {
41+
description: 'update proxy for HTTPS to host',
42+
type: 'string',
43+
})
44+
.option('no-proxy', {
45+
description: 'set no-proxy to host',
46+
type: 'string',
47+
})
3248
.option('debug', {
3349
description: 'turn on debug mode',
3450
type: 'boolean',

lisp/_prepare.el

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
(require 'package)
66
(require 'project)
7+
(require 'url-vars)
78

89
(require 'cl-lib)
910
(require 'rect)
@@ -59,16 +60,36 @@
5960
(nth 1 (eask--flag flag)))
6061

6162
;;; Boolean
62-
(defun eask-global-p () (eask--flag "-g")) ; -g is enabled
63-
(defun eask-force-p () (eask--flag "-f")) ; -f is enabled
64-
(defun eask-dev-p () (eask--flag "--dev")) ; --dev is enabled
63+
(defun eask-global-p () (eask--flag "-g")) ; -g, --global
64+
(defun eask-force-p () (eask--flag "-f")) ; -f, --force
65+
(defun eask-dev-p () (eask--flag "--dev")) ; --dev, --development
66+
(defun eask-debug-p () (eask--flag "--debug")) ; --debug
6567

6668
;;; String (with arguments)
67-
;; XXX Add string argument here if any!
69+
(defun eask-proxy () (eask--flag-value "--proxy"))
70+
(defun eask-http-proxy () (eask--flag-value "--http-proxy"))
71+
(defun eask-https-proxy () (eask--flag-value "--https-proxy"))
72+
(defun eask-no-proxy () (eask--flag-value "--no-proxy"))
6873

6974
;;; Number (with arguments)
7075
(defun eask-depth () (eask--str2num (eask--flag-value "--depth"))) ; --depth is enabled
7176

77+
(defun eask--handle-global-options ()
78+
"Handle global options."
79+
(when (eask-debug-p) (setq debug-on-error t))
80+
(eask--add-proxy "http" (eask-proxy))
81+
(eask--add-proxy "https" (eask-proxy))
82+
(eask--add-proxy "http" (eask-http-proxy))
83+
(eask--add-proxy "https" (eask-https-proxy))
84+
(eask--add-proxy "no_proxy" (eask-no-proxy)))
85+
86+
;;
87+
;;; Proxy
88+
89+
(defun eask--add-proxy (protocal host)
90+
"Add proxy."
91+
(when host (push (cons protocal (eask-proxy)) url-proxy-services)))
92+
7293
;;
7394
;;; Execution
7495

@@ -113,7 +134,10 @@ current workspace.")
113134
other scripts internally. See function `eask-call'.")
114135

115136
(defconst eask--command-list
116-
'("--eask-g" "--eask-f" "--eask--depth" "--eask--dev")
137+
(mapcar (lambda (elm) (concat "--eask" elm))
138+
'("-g" "-f" "--depth" "--dev"
139+
"--proxy" "--http-proxy" "--https-proxy" "--no-proxy"
140+
"--debug" "--verbose" "--silent"))
117141
"List of commands to accept, so we can avoid unknown option error.")
118142

119143
(defun eask-self-command-p (arg)
@@ -193,6 +217,7 @@ Eask file in the workspace."
193217
(user-init-file (locate-user-emacs-file "init.el"))
194218
(custom-file (locate-user-emacs-file "custom.el")))
195219
(setq eask-file (expand-file-name "../../Eask" user-emacs-directory))
220+
(eask--handle-global-options)
196221
(ignore-errors (make-directory package-user-dir t))
197222
(eask--alias-env (load-file eask-file))
198223
(run-hooks 'eask-before-command-hook)

0 commit comments

Comments
 (0)