From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12055 invoked by alias); 28 Jan 2017 20:45:19 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40450 Received: (qmail 11448 invoked from network); 28 Jan 2017 20:45:19 -0000 X-Qmail-Scanner-Diagnostics: from ppa01.princeton.edu by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(128.112.128.213):SA:0(-5.5/5.0):. Processed in 1.911797 secs); 28 Jan 2017 20:45:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: zhimingw@princeton.edu X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at princeton.edu designates 128.112.128.213 as permitted sender) From: Zhiming Wang To: Bart Schaefer CC: Zsh hackers list Subject: Re: Completion of swift fails when swift(1) is from Apple, not OpenStack Thread-Topic: Completion of swift fails when swift(1) is from Apple, not OpenStack Thread-Index: AQHSeYzTxglze6lw3kCbS8XOHZVIVaFOg9UAgAAqRgA= Date: Sat, 28 Jan 2017 20:40:00 +0000 Message-ID: <7143D684-6FEB-4DF3-84CB-BE4F8656EFF1@princeton.edu> References: <9787F242-39F4-4151-85A1-3F6A109A9FB1@princeton.edu> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [140.180.188.12] Content-Type: multipart/signed; boundary="Apple-Mail=_594025F9-E231-4743-926F-1DA4CB18BAF7"; protocol="application/pgp-signature"; micalg=pgp-sha512 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-28_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=quarantine_notspam policy=quarantine score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701280210 --Apple-Mail=_594025F9-E231-4743-926F-1DA4CB18BAF7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Jan 28, 2017, at 1:08 PM, Bart Schaefer = wrote: >=20 > Probably the right thing is to add _swift, and use _pick_variant to = choose > whether to call _openstack or to complete Apple's compiler options. Good call. I am attaching an implementation of _swift. Though I'd very = much like to parse --help output programmatically, some intricacies (like which = options can be repeated) are simply not visible from --help, so I'm hard coding = options. Hopefully Swift is stable enough that options won't fluctuate much = across versions. =46rom 0be3d1c9ac83bc46e8ce30ee5f0220bfca97395e Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Sat, 28 Jan 2017 15:33:45 -0500 Subject: [PATCH] Completion/Unix/Command/_swift: new swift/swiftc = completions swift(1) and swiftc(1) are part of the Swift programming language. https://swift.org/ _swift was written against Apple Swift version 3.0.2. Note that swift(1) conflicts with the command of the same name from = OpenStack. Completion is delegated to _openstack when swift(1) is detected to be = from OpenStack. --- Completion/Unix/Command/_swift | 123 = +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Completion/Unix/Command/_swift diff --git a/Completion/Unix/Command/_swift = b/Completion/Unix/Command/_swift new file mode 100644 index 000000000..6776f0dea --- /dev/null +++ b/Completion/Unix/Command/_swift @@ -0,0 +1,123 @@ +#compdef swift swiftc + +# swift(1) and swiftc(1) are part of the Swift programming language. +# https://swift.org/ + +local -a common_options swiftc_mode_options swiftc_additional_options +local -A swiftc_modes + +common_options=3D( + '-assert-config[specify the assert_configuration = replacement]:config:(Debug Release Unchecked DisableReplacement)' + '*-D[marks a conditional compilation flag as true]:flag:' + '*-framework[specifies a framework which should be linked = against]:framework:' + '*-F[add directory to framework search path]:path:_files -/' + '(-gnone)-gdwarf-types[emit full DWARF type info]' + '(-gnone)-gline-tables-only[emit minimal debug info for backtraces = only]' + '(-gdwarf-types -gline-tables-only -g)-gnone[do not emit debug info]' + '(-gnone)-g[emit debug info]' + '(- : *)-help[display available options]' + '-index-store-path[store indexing data to the specified = path]:directory:_files -/' + '*-I[add directory to the import search path]:path:_files -/' + '-j[number of commands to execute in parallel]:count:' + '*-L[add directory to library link search path]:path:_files -/' + '*-l-[specifies a library which should be linked against]:library:' + '-module-cache-path[specifies the Clang module cache = path]:path:_files -/' + '-module-link-name[library to link against when using this = module]:name:' + '-module-name[name of the module to build]:name:' + '-nostdimport[do not search the standard library import path for = modules]' + '-num-threads[enable multi-threading and specify number of = threads]:count:' + '(-Ounchecked -O)-Onone[compile without any optimization]' + '(-Onone)-Ounchecked[compile with optimizations and remove runtime = safety checks]' + '(-Onone)-O[compile with optimizations]' + '-sdk[compile against SDK]:sdk:_files -/' + '-static-stdlib[statically link the Swift standard library]' + '-suppress-warnings[suppress all warnings]' + '-target-cpu[generate code for a particular CPU variant]:cpu' + '-target[generate code for the given target]:target' + '-use-ld=3D-[specifies the linker to be used]:linker:_files -/' + '(- : *)-version[print version information and exit]' + '-v[show commands to run and use verbose output]' + '-warnings-as-errors[treat warnings as errors]' + '*-Xcc[pass argument to the C/C++/Objective-C compiler]:arg:' + '*-Xlinker[specifies an option which should be passed to the = linker]:option:' +) + +swiftc_modes=3D( + -dump-ast 'parse and type-check input file(s) and dump AST(s)' + -dump-parse 'parse input file(s) and dump AST(s)' + -dump-type-refinement-contexts + 'type-check input file(s) and dump type refinement = contexts(s)' + -emit-assembly 'emit assembly file(s) (-S)' + -emit-bc 'emit LLVM BC file(s)' + -emit-executable 'emit a linked executable' + -emit-ir 'emit LLVM IR file(s)' + -emit-library 'emit a linked library' + -emit-object 'emit object file(s) (-c)' + -emit-sibgen 'emit serialized AST + raw SIL file(s)' + -emit-sib 'emit serialized AST + canonical SIL file(s)' + -emit-silgen 'emit raw SIL file(s)' + -emit-sil 'emit canonical SIL file(s)' + -parse 'parse input file(s)' + -print-ast 'parse and type-check input file(s) and pretty print = AST(s)' +) +local mode +for mode in ${(k)swiftc_modes}; do + # Mode options are mutually exclusive + = swiftc_mode_options+=3D("(${(k)swiftc_modes})${mode}[$swiftc_modes[$mode]]= ") +done + +swiftc_additional_options=3D( + '-application-extension[restrict code to those available for App = Extensions]' + '-embed-bitcode-marker[embed placeholder LLVM IR data as a marker]' + '-embed-bitcode[embed LLVM IR bitcode as data]' + '-emit-dependencies[emit basic Make-compatible dependencies files]' + '-emit-module-path[emit an importable module to the specified = path]:path:_files -/' + '-emit-module[emit an importable module]' + '-emit-objc-header-path[emit an Objective-C header file to the = specified path]:path:_files -/' + '-emit-objc-header[emit an Objective-C header file]' + '-fixit-all[apply all fixits from diagnostics without any filtering]' + '-fixit-code[get compiler fixits as code edits]' + '-import-underlying-module[implicitly imports the Objective-C half of = a module]' + '-output-file-map[a file which specifies the location of = outputs]:path:_files' + '-o[write output to specified file]:path:_files' + '-parse-as-library[parse the input file(s) as libraries, not = scripts]' + '-parse-sil[parse the input file as SIL code, not Swift source]' + '-parseable-output[emit textual output in a parseable format]' + '-profile-coverage-mapping[generate coverage data for use with = profiled execution counts]' + '-profile-generate[generate instrumented code to collect execution = counts]' + '-sanitize-coverage=3D-[specify the type of coverage instrumentation = for Sanitizers and additional options separated by commas]:type:' + '*-sanitize=3D-[turn on runtime checks for erroneous = behavior]:check:' + '-save-temps[save intermediate compilation results]' + '-serialize-diagnostics[serialize diagnostics in a binary format]' + '-tools-directory[look for external executables (ld, clang, binutils) = in the specified directory]:directory:_files -/' + '-whole-module-optimization[optimize input files together instead of = individually]' +) + +case "$words[1]" in + swift) + # The name swift conflicts with the command with the same name from = the + # OpenStack project. We delegate completion to _openstack if = swift(1) is + # detected to be from OpenStack. + local variant + _pick_variant -r variant openstack=3DOpenStack swiftlang=3D'Swift = compiler' unknown --help + case $variant in + openstack) + _openstack "$@" + ;; + swiftlang) + _arguments \ + "$common_options[@]" \ + '*:input:_files' + ;; + *) + _default "$@" + esac + ;; + swiftc) + _arguments \ + "$swiftc_mode_options[@]" \ + "$common_options[@]" \ + "$swiftc_additional_options[@]" \ + '*:input:_files' + ;; +esac -- 2.11.0 --Apple-Mail=_594025F9-E231-4743-926F-1DA4CB18BAF7 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJYjQGgAAoJEFtY+V7JWWXYqcgP/AzB+bPDh7XQN19RyyjsXpw+ jENa3prdV5MZB7xWoihrz4ZBlPbSSp2S8P2/KdlCqCt+He2KNDmpOfcF36rrq1HW KKegEeuzHcJywls6PXDeV2m5x2wtdG9x1tbOSDjtHwDn8GXp5lQkU+LfMeGBZG9w P8DVBGukmAP+joCy7AXSp9L97p/V3QSBEDGVLV9LOcstIUYVmdC88+WIdmKdrgkQ Mpw5U4hMU9QqMZrajw0xsF/ZS2ZtVKWuwiYn12AC1doOhMGAzJVAWAh6ZzsytO/k h8xejFCIIDZhiSf/w+Gm6c5yLUE7SoWVWnEPykwpSG1I2LdNfBuchie6PBxynzit /LQuIPVnI8G2dB8/CsHM86osiJXxvCJFBCbetoV1vOD3yBtz1Q4swK8XLLxhOKUo lkfE1TKxnyc8ltemr7Pm4oU8xTeUvGfeOOjwJo5Vbss5aOGqveFCb4/ATnRIU+LX 4ULYlPanXYbdigY5Be4UWNVISfsrXcXchZj9VZx+g7reIt+VpQ55R2fuw7OWOpEa MHKMv5WMDVQd4eog61idXXRayYLVN/y0tj0QozDPgqPiIyW4y3IX0R+fRbRTEM6E 7WcW16Y0Vq9bEZaSNmue/VPzyXf6fDI3C44hz2qRGS3S9XI+7Mk7cKxl99PvxJz2 JpOWWgoNL7r2hlZwroe0 =H0eD -----END PGP SIGNATURE----- --Apple-Mail=_594025F9-E231-4743-926F-1DA4CB18BAF7--