1
+ #compdef force
2
+ # ------------------------------------------------------------------------------
3
+ # Copyright (c) 2017 Github zsh-users - http://github.com/zsh-users
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ # * Neither the name of the zsh-users nor the
14
+ # names of its contributors may be used to endorse or promote products
15
+ # derived from this software without specific prior written permission.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ # DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
21
+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ # ------------------------------------------------------------------------------
28
+ # Description
29
+ # -----------
30
+ #
31
+ # Completion script for force CLI 0.22.39 (https://github.com/heroku/force).
32
+ #
33
+ # ------------------------------------------------------------------------------
34
+ # Authors
35
+ # -------
36
+ #
37
+ # * Peter Limbach <https://github.com/pelim>
38
+ #
39
+ # ------------------------------------------------------------------------------
40
+
41
+ local -a _1st_arguments
42
+ _1st_arguments=(
43
+ 'apiversion:Display/Set current API version'
44
+ 'login:force login [-i=<instance>] [<-u=username> <-p=password>]'
45
+ 'logout:Log out from force.com'
46
+ 'logins:List force.com logins used'
47
+ 'active:Show or set the active force.com account'
48
+ 'whoami:Show information about the active account'
49
+ 'describe:Describe the object or list of available objects'
50
+ 'sobject:Manage standard & custom objects'
51
+ 'bigobject:Manage big objects'
52
+ 'field:Manage sobject fields'
53
+ 'record:Create, modify, or view records'
54
+ 'bulk:Load csv file use Bulk API'
55
+ 'fetch:Export specified artifact(s) to a local directory'
56
+ 'import:Import metadata from a local directory'
57
+ 'export:Export metadata to a local directory'
58
+ 'query:Execute a SOQL statement'
59
+ 'apex:Execute anonymous Apex code'
60
+ 'trace:Manage trace flags'
61
+ 'log:Fetch debug logs'
62
+ 'eventlogfile:List and fetch event log file'
63
+ 'oauth:Manage ConnectedApp credentials'
64
+ 'test:Run apex tests'
65
+ 'security:Displays the OLS and FLS for a give SObject'
66
+ 'version:Display current version'
67
+ 'update:Update to the latest version'
68
+ 'push:Deploy artifact from a local directory'
69
+ 'aura:force aura push -f <filepath>'
70
+ 'password:See password status or reset password'
71
+ 'notify:Should notifications be used'
72
+ 'limits:Display current limits'
73
+ 'help:Show this help'
74
+ 'datapipe:Manage DataPipes'
75
+ )
76
+
77
+ local -a _field_arguments
78
+
79
+
80
+ _apex_types=(
81
+ 'string' 'textarea' 'longtextarea' 'richtextarea'
82
+ 'boolean' 'double' 'number' 'autonumber' 'picklist'
83
+ 'lookup' 'masterdetail' 'geolocation'
84
+ )
85
+
86
+ _field_arguments=(
87
+ 'list' 'create' 'delete' 'type'
88
+ )
89
+
90
+ _sobject_arguments=(
91
+ 'list' 'create' 'delete'
92
+ )
93
+
94
+ _bulk_arguments=(
95
+ 'insert:upload a .csv file to insert records'
96
+ 'update:upload a .csv file to update records'
97
+ 'query:run a SOQL statement to generate a .csv file on the server'
98
+ 'retrieve:retrieve a query generated .csv file from the server'
99
+ 'job:get information about a job based on job Id'
100
+ 'batch:get detailed information about a batch within a job based on job Id and batch Id'
101
+ 'batches:get a list of batches associated with a job based on job Id'
102
+ )
103
+
104
+ __sobject_list() {
105
+ _wanted application expl 'sobjects' compadd $(force sobject list)
106
+ }
107
+
108
+ __log_list() {
109
+ _wanted application expl 'logfiles' compadd $(force log | grep -o -e '07\w*')
110
+ }
111
+
112
+ __login_user_list() {
113
+ # remove active user string, remove colors & print the username
114
+ _wanted application expl 'usernames' compadd $(force logins | sed 's/(active)//' | sed 's,$(printf "\033"")\\[[0-9;]*[a-zA-Z],,g' | awk '{print $1}')
115
+ }
116
+
117
+ __login_instance_list() {
118
+ _wanted application expl 'instances' compadd $(force logins | awk '{print $3}' | sed 's/https:\/\///')
119
+ }
120
+
121
+ __sobject_command () {
122
+ local curcontext="$curcontext" state line
123
+ typeset -A opt_args
124
+
125
+ _arguments -C \
126
+ ':command:->command' \
127
+ '*::options:->options'
128
+
129
+ case $state in
130
+ (command)
131
+ _describe -t commands "sobject commands" _sobject_arguments
132
+ return
133
+ ;;
134
+
135
+ (options)
136
+ case $line[1] in
137
+ (delete)
138
+ _arguments ':feature:__sobject_list'
139
+ ;;
140
+ esac
141
+ ;;
142
+ esac
143
+ }
144
+
145
+ __field_command () {
146
+ local curcontext="$curcontext" state line
147
+ typeset -A opt_args
148
+
149
+ _arguments -C \
150
+ ':command:->command' \
151
+ '*::options:->options'
152
+
153
+ case $state in
154
+ (command)
155
+ _describe -t commands "field commands" _field_arguments
156
+ return
157
+ ;;
158
+
159
+ (options)
160
+ case $line[1] in
161
+ (list)
162
+ _arguments ':feature:__sobject_list'
163
+ ;;
164
+ (type)
165
+ _describe -t commands "apex types" _apex_types
166
+ return
167
+ ;;
168
+ esac
169
+ ;;
170
+ esac
171
+ }
172
+
173
+ local expl
174
+ local -a active logins
175
+
176
+ local curcontext="$curcontext" state line
177
+ local -A opt_args
178
+
179
+ _arguments -C \
180
+ ':command:->command' \
181
+ '*::options:->options'
182
+
183
+ case $state in
184
+ (command)
185
+ _describe -t commands "force commands" _1st_arguments
186
+ return
187
+ ;;
188
+
189
+ (options)
190
+ case $line[1] in
191
+ (help)
192
+ _describe -t commands "command help" _1st_arguments
193
+ return
194
+ ;;
195
+
196
+ (login)
197
+ _arguments \
198
+ '-u[salesforce user]:userame:__login_user_list' \
199
+ '-i[salesforce instance]:instance:__login_instance_list' \
200
+ '-p[salesforce password]'
201
+ ;;
202
+ (bulk)
203
+ _arguments \
204
+ '-c[bulk command]:_bulk_arguments'
205
+ ;;
206
+
207
+ (log)
208
+ _arguments ':feature:__log_list'
209
+ ;;
210
+
211
+ (field)
212
+ __field_command
213
+ ;;
214
+
215
+ (sobject)
216
+ __sobject_command
217
+ ;;
218
+
219
+ esac
220
+ ;;
221
+ esac
0 commit comments